digitalmars.D.learn - core.atomic.atomicStore and structs
- Saurabh Das (46/46) Mar 03 2020 Hi,
- MoonlightSentinel (2/3) Mar 03 2020 That is a bug, see https://issues.dlang.org/show_bug.cgi?id=20629
- Saurabh Das (5/9) Mar 03 2020 Oh wow you fixed it already! Amazing!
- MoonlightSentinel (2/3) Mar 03 2020 Yes, this fix will be in the upcoming release.
- Saurabh Das (4/7) Mar 03 2020 Excellent.
Hi,
Consider this code:
```
import core.atomic;
struct MyStruct
{
uint a, b;
}
static assert(MyStruct.sizeof == ulong.sizeof);
void main()
{
shared MyStruct ms1;
MyStruct ms2 = atomicLoad(ms1); // This is fine
MyStruct ms3;
cas(&ms1, ms2, ms3); // This is also fine
atomicStore(ms1, ms2); // This gives a compile
error
}
```
This used to work in DMD 2.088.1. It does not work in the latest
DMD 2.091.0-beta.2. It gives a compile error like this:
```
/home/ec2-user/dlang/dmd-2.091.0-beta.2/linux/bin64/../../src/druntime/import/core/int
rnal/atomic.d(233): Error: template core.internal.atomic.atomicExchange cannot
deduce function from argument types !(cast(MemoryOrder)5, false)(MyStruct*,
MyStruct), candidates are:
/home/ec2-user/dlang/dmd-2.091.0-beta.2/linux/bin64/../../src/druntime/import/core/int
rnal/atomic.d(291): atomicExchange(MemoryOrder order = MemoryOrder.seq,
bool result = true, T)(T* dest, T value)
with order = order,
result = false,
T = MyStruct
whose parameters have the following constraints:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> is(T : ulong)
or:
> is(T == class)
or:
> is(T == interface)
or:
> is(T U : U*)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Tip: not satisfied constraints are marked with >
/home/ec2-user/dlang/dmd-2.091.0-beta.2/linux/bin64/../../src/druntime/import
core/atomic.d(127): Error: template instance
core.internal.atomic.atomicStore!(cast(MemoryOrder)5, MyStruct) error
instantiating
/home/ec2-user/dlang/dmd-2.091.0-beta.2/linux/bin64/../../src/druntime/import
core/atomic.d(142): instantiated from here:
atomicStore!(cast(MemoryOrder)5, MyStruct, MyStruct)
atomic_test.d(18): instantiated from here:
atomicStore!(cast(MemoryOrder)5, MyStruct, MyStruct)
```
Is this supposed to not work anymore? Or is this a bug?
Thanks,
Saurabh
Mar 03 2020
On Tuesday, 3 March 2020 at 09:12:40 UTC, Saurabh Das wrote:Is this supposed to not work anymore? Or is this a bug?That is a bug, see https://issues.dlang.org/show_bug.cgi?id=20629
Mar 03 2020
On Tuesday, 3 March 2020 at 10:57:36 UTC, MoonlightSentinel wrote:On Tuesday, 3 March 2020 at 09:12:40 UTC, Saurabh Das wrote:Oh wow you fixed it already! Amazing! Thanks MoonlightSentinel. Saurabh PS: Any chance this will make it into DMD 2.091.0?Is this supposed to not work anymore? Or is this a bug?That is a bug, see https://issues.dlang.org/show_bug.cgi?id=20629
Mar 03 2020
On Tuesday, 3 March 2020 at 11:04:53 UTC, Saurabh Das wrote:PS: Any chance this will make it into DMD 2.091.0?Yes, this fix will be in the upcoming release.
Mar 03 2020
On Tuesday, 3 March 2020 at 11:35:35 UTC, MoonlightSentinel wrote:On Tuesday, 3 March 2020 at 11:04:53 UTC, Saurabh Das wrote:Excellent. Thank you so much! :) SaurabhPS: Any chance this will make it into DMD 2.091.0?Yes, this fix will be in the upcoming release.
Mar 03 2020








Saurabh Das <saurabh.das gmail.com>