Hello, Am Sonntag, den 23.11.2014, 02:47 +0100 schrieb Joakim Sindholt: > GCC 4.9: > > typedef _Atomic struct > { > #if __GCC_ATOMIC_TEST_AND_SET_TRUEVAL == 1 > _Bool __val; > #else > unsigned char __val; > #endif > } atomic_flag; > > Clang 3.6: > > #ifdef __cplusplus > typedef _Atomic(bool) atomic_bool; > #else > typedef _Atomic(_Bool) atomic_bool; > #endif > > typedef struct atomic_flag { atomic_bool _Value; } atomic_flag; So they fucked it up and have incompatible declarations? Great. Please, first of all don't look at it for the #ifdef things, this is secondary, in particular if it never triggers in real life (but I think it does), see below. These two declarations are incompatible and having to compilation units one compiled with gcc and one with clang that are linked together, leads to UB: - the structures should end up to have the same layout, but here one has a qualified field and the other not, so not the same types. - for struct types to be compatible, the struct tag must be the same For the discussion about the second case for the type, this is the question if there are archs that implement TAS operations with other values than 0 for "unset" and 1 for "set". There seem to be archs out there that implement TAS with other values, I vaguely remember having heard about some risk arch (??). Actually this also is the reason why the standard defines this type in such a weird manner, and why per the standard it needs a dedicated initialization macro, default initialization with 0 doesn't do in all cases. Jens -- :: INRIA Nancy Grand Est ::: AlGorille ::: ICube/ICPS ::: :: ::::::::::::::: office Strasbourg : +33 368854536 :: :: :::::::::::::::::::::: gsm France : +33 651400183 :: :: ::::::::::::::: gsm international : +49 15737185122 :: :: http://icube-icps.unistra.fr/index.php/Jens_Gustedt ::