Bug 3672 – [tdpl] read-modify-write (rmw) operators must be disabled for shared
Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2010-01-04T08:51:00Z
Last change time
2014-06-01T12:56:23Z
Keywords
accepts-invalid, bounty, pull
Assigned to
andrej.mitrovich
Creator
andrei
Comments
Comment #0 by andrei — 2010-01-04T08:51:32Z
shared int x;
void main()
{
x++;
}
This compiles but it shouldn't. For a shared word-sized object, only reading and writing it are allowed, as well as shared and synchronized calls where applicable.
Comment #1 by yebblies — 2012-01-30T17:33:30Z
Since this is a couple of years old, can you confirm that this is still what is desired?
Essentially shared variables act like rvalues except for assignment?
Is the compiler expected to make reads/writes atomic or is it better disabled completely and left to atomicStore/atomicLoad etc?
Comment #2 by andrej.mitrovich — 2013-02-04T18:26:54Z
CC'ing Andrei for update.
Comment #3 by andrei — 2013-03-23T17:28:09Z
I've had a discussion with Walter in which we agreed that atomic increment should NOT be generated implicitly for shared variables. Herb Sutter also agrees that C++11 made a mistake adding the sugar to atomic<T> and recommends using named functions.
Code using operands with shared data should not compile. Named functions should provide the appropriate primitives.
There is no issue of code breakage because the code listed was behaving incorrectly to start with.
Comment #4 by andrej.mitrovich — 2014-01-06T11:52:15Z
yebblies do you intend to write a pull for this?
Comment #5 by yebblies — 2014-01-06T17:53:35Z
(In reply to comment #4)
> yebblies do you intend to write a pull for this?
Not currently.
Comment #6 by andrej.mitrovich — 2014-01-07T00:57:13Z