public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/64440] New: -Wdiv-by-zero false negative on const variables
@ 2014-12-30  2:27 chengniansun at gmail dot com
  2014-12-30  3:01 ` [Bug c/64440] " pinskia at gcc dot gnu.org
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: chengniansun at gmail dot com @ 2014-12-30  2:27 UTC (permalink / raw)
  To: gcc-bugs

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.
$:


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2015-01-07  8:22 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-12-30  2:27 [Bug c/64440] New: -Wdiv-by-zero false negative on const variables chengniansun at gmail dot com
2014-12-30  3:01 ` [Bug c/64440] " pinskia at gcc dot gnu.org
2014-12-30  7:53 ` chengniansun at gmail dot com
2014-12-30 12:31 ` manu at gcc dot gnu.org
2015-01-06 15:23 ` mpolacek at gcc dot gnu.org
2015-01-06 16:07 ` mpolacek at gcc dot gnu.org
2015-01-07  8:22 ` mpolacek at gcc dot gnu.org
2015-01-07  8:22 ` mpolacek at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).