https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115791
Bug ID: 115791 Summary: division by zero check missing at optimization levels -O2 and -O3 Product: gcc Version: 10.5.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 58592 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=58592&action=edit testcase OS: Ubuntu 22.04.3 LTS We found a case that UBSAN failed to report division by zero when compiling with gcc-10.5.0 at optimization levels -O2 and -O3. $ ../compiler-builds/gcc-10.5.0_build/bin/gcc -fsanitize=undefined -fsanitize=address -g -lgcc_s -I/home/csmith/include/csmith-2.3.0 -O2 testcase.c -o exec $ timeout 1s ./exec 2>exec.err AddressSanitizer:DEADLYSIGNAL ================================================================= ==3701326==ERROR: AddressSanitizer: FPE on unknown address 0x00000040133d (pc 0x00000040133d bp 0x000000000001 sp 0x7fff7c034130 T0) #0 0x40133d in func_1 testcase.c:20 #1 0x40133d in main testcase.c:29 #2 0x7aaedd229d8f in __libc_start_call_main ../sysdeps/x86/libc-start.c:58 #3 0x7aaedd229e3f in __libc_start_main_impl ../sysdeps/nptl/libc_start_call_main.h:392 #4 0x4014d4 in _start (./exec23+0x4014d4) AddressSanitizer can not provide additional info. SUMMARY: AddressSanitizer: FPE testcase.c:20 in func_1 ==3701326==ABORTING $ ../compiler-builds/gcc-11.4.0_build/bin/gcc -fsanitize=undefined -fsanitize=address -g -lgcc_s -I/home/csmith/include/csmith-2.3.0 -O2 testcase.c -o exec $ timeout 1s ./exec 2>exec.err testcase.c:20:382: runtime error: division by zero