https://gcc.gnu.org/bugzilla/show_bug.cgi?id=123172
Bug ID: 123172
Summary: explicit __atomic_*() calls on _BitInt(>64) assume the
data is 16-byte aligned
Product: gcc
Version: 16.0
Status: UNCONFIRMED
Keywords: wrong-code
Severity: normal
Priority: P3
Component: target
Assignee: unassigned at gcc dot gnu.org
Reporter: zsojka at seznam dot cz
Target Milestone: ---
Host: x86_64-pc-linux-gnu
Target: x86_64-pc-linux-gnu
Created attachment 63071
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=63071&action=edit
testcase
When using the __atomic_*() builtins on _BitInt(>64), a call to __atomic_*_16
is generated. It uses the VMOVDQA or CMPXCHG16B instruction , which will cause
GPF if the data is not aligned to 16B; it might not be, since _BitInt() is
aligned at most to 8B boundary.
_Atomic _BitInt(>64) does not have this issue, since it gets aligned to 16B (I
haven't searched the ABI for this detail).
$ x86_64-pc-linux-gnu-gcc al.c -Wall -W
$ ./a.out
Segmentation fault ./a.out