Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

atomicOp wrong results for double or infinite loop #3000

Closed
fyfrey opened this issue Feb 14, 2019 · 1 comment
Closed

atomicOp wrong results for double or infinite loop #3000

fyfrey opened this issue Feb 14, 2019 · 1 comment

Comments

@fyfrey
Copy link

fyfrey commented Feb 14, 2019

Hi everyone,
I just stumbled upon a weird bug with atomicOp!"+=" on double variables. float is not affected. System: Arch Linux x64.
The following code works fine with dmd but fails with ldc (1.13 and 1.14 beta, both debug and optimized release):

import core.atomic;
import std.stdio;
void main()
{
    shared double data = 0.1;
    data.atomicOp!"+="(0.1);
    writeln(data); // prints 0.2 with dmd, 0.6 with ldc
}

If you further change one line to data.atomicOp!"+="(1.0); computation is stuck in an infinite loop.

Edit: When only using values that can be exactly represented (like 1.0 or 0.5) in both initialization and the atomicOp, computation is both correct and fast.

@kinke
Copy link
Member

kinke commented Feb 14, 2019

Wow, thx for reporting.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants