Bug 16230 – core.atomic.atomicLoad removes shared from aggregate types too eagerly

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P1
Component
druntime
Product
D
Version
D2
Platform
All
OS
All
Creation time
2016-07-03T12:32:47Z
Last change time
2019-08-18T22:25:05Z
Keywords
pull
Assigned to
ag0aep6g
Creator
ag0aep6g

Comments

Comment #0 by ag0aep6g — 2016-07-03T12:32:47Z
import core.atomic; struct S { int* p; } class C { int i; } shared int i = 0; shared int* p = &i; shared int[] a = [0]; shared S s = shared S(&i); shared C c = new C; void main() { auto j = atomicLoad(i); pragma(msg, typeof(j)); /* "int" - Ok, it's a copy. */ auto q = atomicLoad(p); pragma(msg, typeof(q)); /* "shared(int)*" - Good. */ auto b = atomicLoad(a); pragma(msg, typeof(b)); /* "shared(int)[]" - Good. */ auto t = atomicLoad(s); pragma(msg, typeof(t)); /* "S" - Bad. */ auto d = atomicLoad(c); pragma(msg, typeof(d)); /* "C" - Bad. */ /* t and d refer to shared data, but their types are completely un-shared. The point of shared has been defeated. For example, I can now accidentally use ++ on the ints: */ ++*t.p; /* No deprecation. Bad. */ ++d.i; /* Ditto. */ /* With q and b I get a deprecation message, because they're properly typed: */ ++*q; /* "Deprecation: read-modify-write operations are not allowed for shared variables. Use core.atomic.atomicOp!"+="(*q, 1) instead." Good. */ ++b[0]; /* Ditto. */ }
Comment #1 by ag0aep6g — 2016-07-03T19:27:48Z
Comment #2 by github-bugzilla — 2017-08-01T13:09:22Z
Commits pushed to master at https://github.com/dlang/phobos https://github.com/dlang/phobos/commit/7e87d0646a3c2177e41253c7b9c3fca09c6fb08f prepare for fix of druntime issue 16230 https://github.com/dlang/phobos/commit/b97aa79fb60bdba7a8ab08cf7341b077a5b5efba Merge pull request #5665 from aG0aep6G/16230 prepare for fix of druntime issue 16230 merged-on-behalf-of: Petar Kirov <[email protected]>
Comment #3 by github-bugzilla — 2017-08-16T13:24:28Z
Comment #4 by github-bugzilla — 2017-09-01T14:37:00Z
Commits pushed to master at https://github.com/dlang/druntime https://github.com/dlang/druntime/commit/7efd0fe5093ac75bf10065f1d3e7951abcc2b334 fix issue 16230 - core.atomic.atomicLoad removes shared from aggregate types too eagerly https://github.com/dlang/druntime/commit/c87a1b95803c0691b8b181a7c6f1efe8817554e8 add changelog entry for issue 16230 https://github.com/dlang/druntime/commit/eab4c63db305a3163666b2f01ff872335dc61dd4 fixup! add changelog entry for issue 16230 https://github.com/dlang/druntime/commit/02d9fc4ffb0f3e790e1840a11c8f3ef13dba68f4 Merge pull request #1605 from aG0aep6G/16230 fix issue 16230 - core.atomic.atomicLoad removes shared from aggregat… merged-on-behalf-of: unknown
Comment #5 by github-bugzilla — 2017-10-16T09:57:13Z
Commits pushed to stable at https://github.com/dlang/druntime https://github.com/dlang/druntime/commit/7efd0fe5093ac75bf10065f1d3e7951abcc2b334 fix issue 16230 - core.atomic.atomicLoad removes shared from aggregate types too eagerly https://github.com/dlang/druntime/commit/c87a1b95803c0691b8b181a7c6f1efe8817554e8 add changelog entry for issue 16230 https://github.com/dlang/druntime/commit/eab4c63db305a3163666b2f01ff872335dc61dd4 fixup! add changelog entry for issue 16230 https://github.com/dlang/druntime/commit/02d9fc4ffb0f3e790e1840a11c8f3ef13dba68f4 Merge pull request #1605 from aG0aep6G/16230
Comment #6 by github-bugzilla — 2018-01-05T13:30:52Z
Comment #7 by ag0aep6g — 2019-08-18T22:25:05Z
*** Issue 12795 has been marked as a duplicate of this issue. ***