Bug 16277 – Can't use atomicStore with classes or interface
Status
RESOLVED
Resolution
INVALID
Severity
blocker
Priority
P1
Component
druntime
Product
D
Version
D2
Platform
All
OS
All
Creation time
2016-07-13T21:06:14Z
Last change time
2019-08-20T05:53:43Z
Assigned to
No Owner
Creator
ponce
Comments
Comment #0 by aliloko — 2016-07-13T21:06:14Z
Is this normal?
-------------------------------
interface IL
{
}
import core.atomic;
void main()
{
IL i;
shared(IL) j;
atomicStore(j, i);
}
-------------------------------
As of DMD 2.071, this gives an error:
/d391/f135.d(12): Error: template core.atomic.atomicStore cannot deduce function from argument types !()(shared(IL), IL), candidates are: /opt/compilers/dmd2/include/core/atomic.d(1100): core.atomic.atomicStore(MemoryOrder ms = MemoryOrder.seq, T, V1)(ref shared T val, V1 newval) if (__traits(compiles, () { val = newval; } ))
Is that constraint { val = newval; } valid?
I would have thought atomics would work with types who are just pointers, like class instances and interfaces.
Comment #1 by turkeyman — 2019-08-20T05:53:43Z
That's a shared violation.
You can't transfer unshared `IL i` to `shared(IL) j`, that would raise the unshared value to shared, and that would be very bad.