|
|
|
|
|
by banthar
1035 days ago
|
|
This is how all undefined behavior works. It seems to be working now but breaks with new CPU, GCC version or on wrong moon phase. "-Wcast-align=strict" will work in this but not all cases - that's why we have UBSAN: $ gcc -fsanitize=undefined test.c
$ ./a.out
test.c:6:6: runtime error: store to misaligned address 0x55e4007adeb1 for type 'int', which requires 4 byte alignment
0x55e4007adeb1: note: pointer points here
00 00 00 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 51 00 00 00 00
|
|