Strictly speaking, I believe that both compilers are right, as your program exhibits undefined behavior. To quote n4140 (C ++ 14), [atomics.types.operations.req] , focus:
In the following definitions of operations:
- a refers to one of the atomic types.
[...]
A::A() noexcept = default;
Effects: leaves the atomic object in an uninitialized state. [Note: these semantics provide compatibility with C. - end note]
as not initialized before loading. Thus, the usual undefined behavior should follow.
source share