[Bug libstdc++/71660] [5/6/7 regression] alignment of std::atomic<8 byte primitive type> (long long, double) is wrong on x86
redi at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Mon Jun 27 13:06:00 GMT 2016
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71660
Jonathan Wakely <redi at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Last reconfirmed| |2016-06-27
Ever confirmed|0 |1
--- Comment #2 from Jonathan Wakely <redi at gcc dot gnu.org> ---
However alignof(std::atomic<long long>) != alignof(_Atomic long long) for
x86-32, which is wrong, since that was the point of PR65147.
#ifdef __cplusplus
#include <atomic>
using std::atomic_llong;
#else
#include <stdalign.h>
#include <stdatomic.h>
#endif
#include <stdio.h>
struct InStruct { long long x; };
struct AtomicStruct { int i; atomic_llong x; };
int main()
{
printf("%zu %zu %zu %zu\n",
alignof(struct InStruct),
alignof(atomic_llong),
sizeof(struct AtomicStruct),
alignof(struct AtomicStruct));
}
With GCC this prints 4 4 12 4 but with G++ it prints 4 8 16 8
We might need a front-end attribute so std::atomic can emulate what the C
front-end does with _Atomic.
More information about the Gcc-bugs
mailing list