https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80744
Eric Gallager <egallager at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Blocks| |87403
Summary|Detect Divide By Zero and |Detect Possible Division By
|give a warning in C/C++ |Zero and give a warning in
| |C/C++ [-Wmaybe-div-by-zero]
--- Comment #6 from Eric Gallager <egallager at gcc dot gnu.org> ---
(In reply to Martin Sebor from comment #3)
> I agree that diagnosing (A) or (C) under -Wdiv-by-zero would not be
> appropriate because the option controls compile-time division by zero and
> there is none here.
>
> Extending -Wdiv-by-zero to diagnose possible division by zero would
> undoubtedly make the option exceedingly noisy. Introducing a new option
> such as -Wmaybe-div-by-zero analogous to -Wmaybe-uninitialized would be fine
> but the option wouldn't diagnose ether (A) or (C) because there is no
> evidence of overflow. -Wmaybe-uninitialized triggers under very restrictive
> conditions, when there is some evidence that an uninitialized variable is
> used. To avoid excessive noise from -Wmaybe-div-by-zero some similar
> approach would need to used. Such as:
>
> int f (int i)
> {
> int j;
>
> if (i == 0) // because of this test
> j = 7;
> else
> j = 13;
>
> return j / i; // i may be assumed to be zero here
> }
Changing title then to specify -Wmaybe-div-by-zero would be a different
warning, which lets it block the new-warning meta-bug
Referenced Bugs:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87403
[Bug 87403] [Meta-bug] Issues that suggest a new warning