[Bug sanitizer/109151] New: UBsan misses a divide-by-zero
shaohua.li at inf dot ethz.ch
gcc-bugzilla@gcc.gnu.org
Wed Mar 15 21:51:07 GMT 2023
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109151
Bug ID: 109151
Summary: UBsan misses a divide-by-zero
Product: gcc
Version: 13.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: sanitizer
Assignee: unassigned at gcc dot gnu.org
Reporter: shaohua.li at inf dot ethz.ch
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, marxin at gcc dot gnu.org
Target Milestone: ---
For the following code, UBsan failed to report the divide-by-zero, while
Clang's UBsan could.
Compiler explorer: https://godbolt.org/z/Y73vrf8zK
%cat a.c
int a, c;
short b;
long d;
int main() {
a = (short)(d == c | b > 9) / 0;
return a;
}
%
% gcc -fsanitize=undefined a.c &&./a.out
Floating point exception
%
% clang -fsanitize=undefined a.c &&./a.out
/a.c:5:42: runtime error: division by zero
%
More information about the Gcc-bugs
mailing list