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

            Bug ID: 115323
           Summary: [10/11/12 Regression] signed integer overflow check
                    missing at -O0, -O2, -O3, -Os
           Product: gcc
           Version: 12.3.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 58328
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=58328&action=edit
testcase

OS: Ubuntu 22.04.3 LTS
We found some cases that UBSAN missed checking if there's a signed integer
overflow behavior when compiling with gcc-12.3.0 at optimization levels -O0,
-O2, -O3, -Os.
When compiling with gcc-12.3.0 at optimization level -O1, UBSAN can detect the
undefined behavior.

$ ../compiler-builds/gcc-12.3.0_build/bin/gcc -fsanitize=undefined -g -lgcc_s
-I/home/csmith/include/csmith-2.3.0 -O0 testcase.c -o exec

$ timeout 1s ./exec 2>exec.err

$ cat exec.err

$ ../compiler-builds/gcc-12.3.0_build/bin/gcc -fsanitize=undefined -g -lgcc_s
-I/home/csmith/include/csmith-2.3.0 -O1 testcase.c -o exec

$ timeout 1s ./exec 2>exec.err

$ cat exec.err
testcase.c:26:59: runtime error: signed integer overflow: 65495 * 65529 cannot
be represented in type 'int'

Reply via email to