|
|
|
|
|
by charleslmunger
382 days ago
|
|
No, because it's atomic. If that was a data race, and data races are UB, there would be no point in having relaxed atomics. It's not my criterion, it's defined in the language standard. You can't have a data race on an atomic except for std::atomic_init. The reads on the string contents themselves are ordered because the args string is initialized before the thread is launched and the other one is static. If the launched thread allocated a new string and then populated the atomic, that would be a data race, unless stronger memory order was used by both the writer and the reader. |
|