[Bug 84] Writes to struct members marked as shared are not volatile

gdc-bugzilla at gdcproject.org gdc-bugzilla at gdcproject.org
Thu Feb 13 07:01:52 PST 2014


http://bugzilla.gdcproject.org/show_bug.cgi?id=84

--- Comment #6 from Johannes Pfau <johannespfau at gmail.com> 2014-02-13 15:01:52 GMT ---
Not into registers might be OK, but if we have code like this:

-------------
shared int a;
void doSomething()
{
    for(int i = 0; i < 10; i++)
        atomicStore(a, i);
}
-------------

I think it is legal* to optimize the for loop into a single assignment, 'a =
9', for shared variables. This wouldn't be allowed for volatile variables.

* http://www.drdobbs.com/parallel/volatile-vs-volatile/212701484
Basically the 'as if' rule: If the 'doSomething' thread executes much faster
than a thread reading 'a' the reading thread might only see the final value, 9,
anyway.

-- 
Configure bugmail: http://bugzilla.gdcproject.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are watching all bug changes.


More information about the D.gnu mailing list