[Bug c/71949] ATOMIC_FLAG_INIT definition in stdatomic.h

joseph at codesourcery dot com gcc-bugzilla@gcc.gnu.org
Tue Jul 26 21:51:00 GMT 2016


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71949

--- Comment #1 from joseph at codesourcery dot com <joseph at codesourcery dot com> ---
ATOMIC_FLAG_INIT is an initializer, not an expression that can be used in 
assignments.

The C11 model is that it may not be valid to do assignments such as

>   atomic_flag f2;
>   f2 =  ATOMIC_FLAG_INIT;

because an atomic object may need extra state that is specially 
initialized before assignments can be carried out on it (hence 
initialization using separate macros from assignment).

See the response to DR#454, explicitly saying ATOMIC_VAR_INIT is only for 
initialization.  Much the same would apply to ATOMIC_FLAG_INIT.

Now, GCC does not support the cases that require extra state to be 
initialized, but this does not make uses of *_INIT in non-initializers 
valid.


More information about the Gcc-bugs mailing list