[Bug c/69825] New: False -Wdiv-by-zero warning when it should be short-circuited
dgilbert at redhat dot com
gcc-bugzilla@gcc.gnu.org
Mon Feb 15 14:05:00 GMT 2016
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69825
Bug ID: 69825
Summary: False -Wdiv-by-zero warning when it should be
short-circuited
Product: gcc
Version: 5.3.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
Assignee: unassigned at gcc dot gnu.org
Reporter: dgilbert at redhat dot com
Target Milestone: ---
gcc version 5.3.1 20151207 (Red Hat 5.3.1-2) (GCC)
$ cat bug.c
void bug(void)
{
static unsigned int counter = 0;
static const unsigned int frequency = 0;
if (frequency && (!(counter % frequency))) {
}
counter++;
}
$ gcc bug.c -Wall -c -O2
bug.c: In function ‘bug’:
bug.c:6:33: warning: division by zero [-Wdiv-by-zero]
if (frequency && (!(counter % frequency))) {
^
I'm told it also triggers on trunk, 4.6, 5.3 but not 4.8.5
More information about the Gcc-bugs
mailing list