[Bug c++/80744] Detect Divide By Zero and give a warning in C/C++
egallager at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Tue Aug 1 16:39:00 GMT 2017
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80744
Eric Gallager <egallager at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Last reconfirmed| |2017-08-01
CC| |egallager at gcc dot gnu.org
Component|c |c++
Ever confirmed|0 |1
--- Comment #1 from Eric Gallager <egallager at gcc dot gnu.org> ---
Testcase needs some modification to compile properly; after adding the proper
includes and namespace, the results are:
$ /usr/local/bin/g++ -c -Wdiv-by-zero 80744.cc
80744.cc: In function ‘void test_func(size_t, const string&)’:
80744.cc:14:25: warning: division by zero [-Wdiv-by-zero]
printf("B %zu\n", 10/i);
~~^~
$
Confirmed that warnings are still missing for (A) and (C), although maybe there
should be a separate option: -Wmaybe-div-by-zero, analogous to how there's both
-Wmaybe-uninitialized and -Wuninitialized, depending on how certain gcc is.
(Changing component from 'c' to 'c++' while I'm at it since testcase uses
c++-specific things)
More information about the Gcc-bugs
mailing list