https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64440
Bug ID: 64440
Summary: -Wdiv-by-zero false negative on const variables
Product: gcc
Version: 5.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
Assignee: unassigned at gcc dot gnu.org
Reporter: chengniansun at gmail dot com
In the following test case, the variable "b" is constant zero. However, GCC
does not warn div-by-zero on the expression "a / b". More details are shown as
below:
$: cat t.c
int f (int a) {
const int b = 0;
return a / b;
}
$:
$: gcc-trunk -c -Wdiv-by-zero t.c
$:
$: clang-trunk -c -Wdivision-by-zero t.c
t.c:3:12: warning: division by zero is undefined [-Wdivision-by-zero]
return a / b;
^ ~
1 warning generated.
$: