https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115972

            Bug ID: 115972
           Summary: [10/11 Regression] Misaligned address error check
                    missing
           Product: gcc
           Version: 11.4.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 58694
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=58694&action=edit
testcase

We found that gcc-10.5.0 fails to detect a misaligned address error at the Os
optimization level.

$ ~/compiler-builds/gcc-12.3.0_build/bin/gcc -fsanitize=undefined -g -lgcc_s -w
-Os testcase.c -o exec
$ timeout 2s ./exec 2>exec.err
0
$ cat exec.err
testcase.c:19:6: runtime error: store to misaligned address 0x7fff81dcd443 for
type 'int32_t', which requires 4 byte alignment
0x7fff81dcd443: note: pointer points here
 01  00 00 00 02 00 00 00 00  00 00 00 00 02 00 00 00  00 00 00 00 00 00 00 00 
90 dd eb cb b6 7f 00
              ^
testcase.c:20:3: runtime error: load of misaligned address 0x7fff81dcd443 for
type 'int32_t', which requires 4 byte alignment
0x7fff81dcd443: note: pointer points here
 01  00 00 00 00 00 00 00 00  00 00 00 00 02 00 00 00  00 00 00 00 00 00 00 00 
90 dd eb cb b6 7f 00
              ^
testcase.c:21:20: runtime error: load of misaligned address 0x7fff81dcd443 for
type 'int32_t', which requires 4 byte alignment
0x7fff81dcd443: note: pointer points here
 01  00 00 00 00 00 00 00 00  00 00 00 00 02 00 00 00  00 00 00 00 00 00 00 00 
90 dd eb cb b6 7f 00
              ^
$ ~/compiler-builds/gcc-11.4.0_build/bin/gcc -fsanitize=undefined -g -lgcc_s -w
-Os testcase.c -o exec
$ timeout 2s ./exec 2>exec.err
0
$ cat exec.err
$

We also found that gcc-11.4.0 fails to detect a misaligned address error at the
Os optimization level.

Reply via email to