https://bugs.llvm.org/show_bug.cgi?id=49316
Bug ID: 49316
Summary: program with #pragma pack(1) and __int128 behaves
differents under O1 and higher optimization
Product: clang
Version: trunk
Hardware: PC
OS: Linux
Status: NEW
Severity: normal
Priority: P
Component: -New Bugs
Assignee: [email protected]
Reporter: [email protected]
CC: [email protected], [email protected],
[email protected], [email protected]
Following code has different behaviors under different optimization level. I am
not sure whether it is caused by asan or optimization, tbh.
$ cat test.c
#pragma pack(1)
struct {
char a;
__int128 b;
} c;
__int128 *d = &c.b;
int main() { *d = 0; }
In short, when compiling with '-O0', the exit code is 0. But when compiling
with '-O1', the exit code is 139 (segment fault).
O0 (program returns 0): https://godbolt.org/z/x3d68s
O1 (program returns 139): https://godbolt.org/z/bef6T9
O2 (program returns 139): https://godbolt.org/z/brvz77
O3 (program returns 139): https://godbolt.org/z/K8sEaa
Os (program returns 129): https://godbolt.org/z/PxToY5
I further use asan to report more details:
O0 (normal): https://godbolt.org/z/5G9bbv
O1 (segfault): https://godbolt.org/z/3ob34b
AddressSanitizer:DEADLYSIGNAL
=================================================================
==1==ERROR: AddressSanitizer: SEGV on unknown address (pc 0x0000004f3ddc bp
0x000000000000 sp 0x7ffead06c7b0 T0)
==1==The signal is caused by a READ memory access.
==1==Hint: this fault was caused by a dereference of a high value address (see
register values below). Disassemble the provided pc to learn which register
was used.
#0 0x4f3ddc (/app/output.s+0x4f3ddc)
#1 0x7f4b493950b2 (/lib/x86_64-linux-gnu/libc.so.6+0x270b2)
#2 0x41adad (/app/output.s+0x41adad)
AddressSanitizer can not provide additional info.
SUMMARY: AddressSanitizer: SEGV (/app/output.s+0x4f3ddc)
==1==ABORTING
--
You are receiving this mail because:
You are on the CC list for the bug._______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs