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

            Bug ID: 116031
           Summary: signed integer overflow check at optimization level
                    -O3
           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 58720
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=58720&action=edit
testcase

OS: Ubuntu 22.04.3 LTS
We found a case that UBSAN not reporting signed integer overflow when compiling
with gcc-13.2.0 and gcc-14.1.0 at optimization level -O3.

$ ../compiler-builds/gcc-13.2.0_build/bin/gcc -fsanitize=undefined
-fsanitize=address -g -lgcc_s -O3 testcase.c -o exec

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

$ ../compiler-builds/gcc-12.3.0_build/bin/gcc -fsanitize=undefined
-fsanitize=address -g -lgcc_s -O3 testcase.c -o exec

$ timeout 1s ./exec 2>exec.err
testcase.c:22:15: runtime error: signed integer overflow: 754946112 +
1912123656 cannot be represented in type 'int'

I wonder if gcc-13 and gcc-14 have optimized out the part that cause signed
integer overflow.

Reply via email to