https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92299
Luca Rocca <disquisitiones at gmail dot com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|RESOLVED |UNCONFIRMED Resolution|INVALID |--- --- Comment #3 from Luca Rocca <disquisitiones at gmail dot com> --- Division by 0 is always undefined, regardless of the numerator. So, 0 / X should not be simplified if we cannot exclude that X = 0. Then if X = 0 we should expect an exception triggered at runtime, as we have for example for 1 / 0. Consider for comparison the approach of gcc up to gcc-6.4.0, reading this comment from the corresponding file gcc-6.4.0/gcc/match.pd: /* Make sure to preserve divisions by zero. This is the reason why we don't simplify x / x to 1 or 0 / x to 0. */