[Bug middle-end/87237] __atomic_load on 4-byte-sized, 1-byte-aligned struct is not atomic
amonakov at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Tue Sep 11 19:46:00 GMT 2018
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87237
--- Comment #3 from Alexander Monakov <amonakov at gcc dot gnu.org> ---
(In reply to Richard Smith from comment #2)
> I think that's only true for objects whose size corresponds to that of a
> fundamental type. Consider:
>
> struct B { char c[3]; };
>
> Here, an atomic object of type B (eg, _Atomic(B) or std::atomic<B>) would
> have size=4, align=4, and yet GCC treats B as having an alignment of 1 for
> the purpose of atomic accesses.
No, this does not appear to be true. With GCC size/align are 3/1 while with
Clang it's 4/4 as you said:
struct B { char c[3];};
_Atomic struct B b;
int a = _Alignof b;
int s = sizeof b;
s:
.long 3
[...]
a:
.long 1
.comm b,3,1
More information about the Gcc-bugs
mailing list