Thread overview
[Issue 17821] atomicStore compile error when target is larger than source
[Issue 17821] atomicStore is buggy when target is larger than source
Sep 10, 2017
Eyal
Dec 08, 2021
Stanislav Blinov
Dec 17, 2022
Iain Buclaw
September 10, 2017
https://issues.dlang.org/show_bug.cgi?id=17821

Eyal <eyal@weka.io> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |eyal@weka.io, tomer@weka.io

--
September 10, 2017
https://issues.dlang.org/show_bug.cgi?id=17821

Tomer Filiba (weka) <tomer@weka.io> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |industry

--
September 10, 2017
https://issues.dlang.org/show_bug.cgi?id=17821

johanengelen@weka.io changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |johanengelen@weka.io

--- Comment #1 from johanengelen@weka.io ---
The bad codegen bug is LDC specific. DMD errors upon the
atomicStore!(ulong,int) call ("core/atomic.d(1185): Error: bad type/size of
operands 'mov'").

Test cases:
```
    {
        shared ulong x = 0x1234_5678_8765_4321;
        atomicStore(x, 0);
        assert(x == 0);
    }
    {
        struct S
        {
            ulong x;
            alias x this;
        }

        shared S s;
        s = 0x1234_5678_8765_4321;
        atomicStore(s, 0);
        assert(s.x == 0);
    }
```

LDC fix: https://github.com/ldc-developers/druntime/pull/102

I am assuming that we want to preserve the current atomicStore interface, that says it can be called with all types for which `val = newval` is valid.

--
September 11, 2017
https://issues.dlang.org/show_bug.cgi?id=17821

--- Comment #2 from johanengelen@weka.io ---
Fixed in LDC 1.4.0.

The remaining issue is compilation error with DMD for:
```
import core.atomic;
shared ulong x;
atomicStore(x, 0);
```

--
September 11, 2017
https://issues.dlang.org/show_bug.cgi?id=17821

johanengelen@weka.io changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
          Component|phobos                      |druntime
            Summary|atomicStore is buggy when   |atomicStore compile error
                   |target is larger than       |when target is larger than
                   |source                      |source

--
December 08, 2021
https://issues.dlang.org/show_bug.cgi?id=17821

Stanislav Blinov <stanislav.blinov@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |stanislav.blinov@gmail.com

--- Comment #3 from Stanislav Blinov <stanislav.blinov@gmail.com> ---
This compiles since 2.089.1:

void main() {
    import core.atomic;
    {
        shared ulong x = 0x1234_5678_8765_4321;
        atomicStore(x, 0);
        assert(x == 0);
    }
    {
        struct S
        {
            ulong x;
            alias x this;
        }

        shared S s;
        s = 0x1234_5678_8765_4321;
        atomicStore(s, S(0)); // note this is not atomicStore(s, 0);
        assert(s.x == 0);
    }
}

I'm not sure that atomicStore should even try alias this. This can probably be closed as resolved now.

--
December 17, 2022
https://issues.dlang.org/show_bug.cgi?id=17821

Iain Buclaw <ibuclaw@gdcproject.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P3                          |P4

--
December 07
https://issues.dlang.org/show_bug.cgi?id=17821

--- Comment #4 from dlangBugzillaToGithub <robert.schadek@posteo.de> ---
THIS ISSUE HAS BEEN MOVED TO GITHUB

https://github.com/dlang/dmd/issues/17350

DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB

--