Re: Is comparison of shared data thread-safe?

2023-03-17 Thread bauss via Digitalmars-d-learn
On Thursday, 16 March 2023 at 12:32:34 UTC, Nick Treleaven wrote: With -preview=nosharedaccess, I get: int y = 2; shared int x = y; // OK assert(x == 2); // no error y = x; // error So for the assignment to y, reading x is an error and atomicLoad should be used instead. But

Re: Is comparison of shared data thread-safe?

2023-03-16 Thread Nick Treleaven via Digitalmars-d-learn
On Thursday, 16 March 2023 at 12:32:34 UTC, Nick Treleaven wrote: With -preview=nosharedaccess, I get: int y = 2; shared int x = y; // OK assert(x == 2); // no error y = x; // error This also does not error: ```d bool b = x == 3; ``` Filed:

Is comparison of shared data thread-safe?

2023-03-16 Thread Nick Treleaven via Digitalmars-d-learn
With -preview=nosharedaccess, I get: int y = 2; shared int x = y; // OK assert(x == 2); // no error y = x; // error So for the assignment to y, reading x is an error and atomicLoad should be used instead. But is it an oversight that reading x in the assert is not an error?