https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115625
Bug ID: 115625
Summary: [10/11/13 Regression] misaligned address check missing
Product: gcc
Version: 13.2.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: sanitizer
Assignee: unassigned at gcc dot gnu.org
Reporter: bic60176 at gmail dot com
CC: dodji at gcc dot gnu.org, dvyukov at gcc dot gnu.org,
jakub at gcc dot gnu.org, kcc at gcc dot gnu.org
Target Milestone: ---
Created attachment 58509
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=58509&action=edit
Test file used in the report.
OS: Ubuntu 22.04.3 LTS
We found that gcc failed to catch misaligned address errors when compiling with
gcc-13.2.0 at optimization level 1.
$ ~/compiler-builds/gcc-13.2.0_build/bin/gcc -fsanitize=undefined -g -lgcc_s
-I/home/csmith/include/csmith-2.3.0 -O1 testcase.c -o exec
$ timeout 5s ./exec 2>exec.err
$ cat exec.err
$ ~/compiler-builds/gcc-14.1.0_build/bin/gcc -fsanitize=undefined -g -lgcc_s
-I/home/csmith/include/csmith-2.3.0 -O1 testcase.c -o exec
$ timeout 5s ./exec 2>exec.err
$ cat exec.err
testcase.c:25:7: runtime error: load of misaligned address 0x7ffe94ed505a for
type 'int32_t', which requires 4 byte alignment
0x7ffe94ed505a: note: pointer points here
00 00 00 00 00 00 00 00 09 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 01 00 00 00 00 00
^
$
We have found that gcc also fails to catch misaligned address errors in both
gcc-11.4.0 at optimization level 1 and gcc-10.5.0 at optimization level 1.