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

            Bug ID: 115225
           Summary: [11/12/13/14 Regression] signed integer overflow check
                    missing with optimization
           Product: gcc
           Version: 11.4.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: bic60176 at gmail dot com
  Target Milestone: ---

Created attachment 58285
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=58285&action=edit
testcase

OS: Ubuntu 22.04.3 LTS

UBSAN missed checking signed integer overflow when compiling with gcc-11.4.0,
gcc-12.3.0, gcc-13.2.0, gcc-14.1.0 at optimization levels -O1, -O2, -O3, and
-Os.
With optimizer, does UBSAN check signed integer overflow?

$ ../compiler-builds/gcc-13.2.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
testcase.c:7:5: runtime error: signed integer overflow: 1932174879 * 2 cannot
be represented in type 'int'

$ ../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

Reply via email to