https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115273
Bug ID: 115273 Summary: [12 Regression] passing zero to ctz() check missing 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 58305 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=58305&action=edit testcase OS: Ubuntu 22.04.3 LTS We found a case that UBSAN missed checking if zero is passed to __builtin_ctz() when compiling with gcc-12.3.0. When compiling with gcc-11.4.0, gcc-13.2.0, and gcc-14.1.0, 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 testcase.c -o exec $ timeout 1s ./exec 2>exec.err $ cat exec.err $ ../compiler-builds/gcc-11.4.0_build/bin/gcc -fsanitize=undefined -g -lgcc_s -I/home/csmith/include/csmith-2.3.0 testcase.c -o exec $ timeout 1s ./exec 2>exec.err testcase.c:957:44: runtime error: passing zero to ctz(), which is not a valid argument testcase.c:997:25: runtime error: passing zero to ctz(), which is not a valid argument testcase.c:957: runtime error: passing zero to ctz(), which is not a valid argument testcase.c:997: runtime error: passing zero to ctz(), which is not a valid argument testcase.c:957: runtime error: passing zero to ctz(), which is not a valid argument testcase.c:997: runtime error: passing zero to ctz(), which is not a valid argument testcase.c:957: runtime error: passing zero to ctz(), which is not a valid argument testcase.c:997: runtime error: passing zero to ctz(), which is not a valid argument testcase.c:957: runtime error: passing zero to ctz(), which is not a valid argument testcase.c:997: runtime error: passing zero to ctz(), which is not a valid argument testcase.c:957: runtime error: passing zero to ctz(), which is not a valid argument testcase.c:997: runtime error: passing zero to ctz(), which is not a valid argument testcase.c:957: runtime error: passing zero to ctz(), which is not a valid argument testcase.c:997: runtime error: passing zero to ctz(), which is not a valid argument testcase.c:957: runtime error: passing zero to ctz(), which is not a valid argument testcase.c:997: runtime error: passing zero to ctz(), which is not a valid argument testcase.c:957: runtime error: passing zero to ctz(), which is not a valid argument testcase.c:997: runtime error: passing zero to ctz(), which is not a valid argument testcase.c:957: runtime error: passing zero to ctz(), which is not a valid argument testcase.c:997: runtime error: passing zero to ctz(), which is not a valid argument