https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80744
Martin Sebor <msebor at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |msebor at gcc dot gnu.org --- Comment #3 from Martin Sebor <msebor at gcc dot gnu.org> --- 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 }