https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65147
--- Comment #7 from Alexey Lapshin <alexey.lapshin at oracle dot com> --- (In reply to Jonathan Wakely from comment #5) > Author: redi > Date: Thu Mar 26 19:27:02 2015 > New Revision: 221703 > > URL: https://gcc.gnu.org/viewcvs?rev=221703&root=gcc&view=rev > Log: > PR libstdc++/62259 > PR libstdc++/65147 > * include/std/atomic (atomic<T>): Increase alignment for types with > the same size as one of the integral types. > * testsuite/29_atomics/atomic/60695.cc: Adjust dg-error line number. > * testsuite/29_atomics/atomic/62259.cc: New. > > Added: > trunk/libstdc++-v3/testsuite/29_atomics/atomic/62259.cc > - copied, changed from r221701, > trunk/libstdc++-v3/testsuite/29_atomics/atomic/60695.cc > Modified: > trunk/libstdc++-v3/ChangeLog > trunk/libstdc++-v3/include/std/atomic > trunk/libstdc++-v3/testsuite/29_atomics/atomic/60695.cc It looks like this fix makes alignment of atomic object to be the same as alignment of integral non-atomic object of the same size. The gcc behavior is different it makes alignment of atomic objects of sizes 1,2,4,8,16 to match with size : G++ : $ cat all.cc #include <atomic> #include <stdio.h> typedef struct { char c[16]; } S16; int main ( void ) { std::atomic<char> ac; std::atomic<short> as; std::atomic<long> al; std::atomic<long long> all; std::atomic<S16> a16; printf("\n sizeof(ac) %d alignof(ac) %d", sizeof(ac), alignof(ac) ); printf("\n sizeof(as) %d alignof(as) %d", sizeof(as), alignof(as) ); printf("\n sizeof(al) %d alignof(al) %d", sizeof(al), alignof(al) ); printf("\n sizeof(all) %d alignof(all) %d", sizeof(all), alignof(all) ); printf("\n sizeof(a16) %d alignof(a16) %d", sizeof(a16), alignof(a16) ); printf("\n"); } $g++ -latomic -std=c++11 -m32 all.cc $./a.out sizeof(ac) 1 alignof(ac) 1 sizeof(as) 2 alignof(as) 2 sizeof(al) 4 alignof(al) 4 sizeof(all) 8 alignof(all) 4 sizeof(a16) 16 alignof(a16) 1 gcc : $ cat all.c #include <stdatomic.h> #include <stdio.h> typedef struct { char c[16]; } S16; int main ( void ) { _Atomic char ac; _Atomic short as; _Atomic long al; _Atomic long long all; _Atomic S16 a16; printf("\n sizeof(ac) %d alignof(ac) %d", sizeof(ac), __alignof__(ac) ); printf("\n sizeof(as) %d alignof(as) %d", sizeof(as), __alignof__(as) ); printf("\n sizeof(al) %d alignof(al) %d", sizeof(al), __alignof__(al) ); printf("\n sizeof(all) %d alignof(all) %d", sizeof(all), __alignof__(all) ); printf("\n sizeof(a16) %d alignof(a16) %d", sizeof(a16), __alignof__(a16) ); printf("\n"); } $ gcc -latomic -std=c11 -m32 all.c $ ./a.out sizeof(ac) 1 alignof(ac) 1 sizeof(as) 2 alignof(as) 2 sizeof(al) 4 alignof(al) 4 sizeof(all) 8 alignof(all) 8 sizeof(a16) 16 alignof(a16) 16 avl@ficus:~/atomic_test$ Note 8-bytes and 16-bytes objects aligned at their size at -m32.