https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104356
--- Comment #12 from Richard Biener <rguenth at gcc dot gnu.org> --- (In reply to Eric Botcazou from comment #9) > > So for Ada it would be valid to optimize it as > > > > tem = D; > > if (tem != 0) > > D := 1 / tem; > > else > > D = tem; > > > > basically carrying out the division conditionally only? > > (I've tried hard to preserve all volatile loads / stores, if not > > volatile that can be elided) > > No, the result of the operation is not dead here (modulo Volatile), so the > operation must be performed and therefore raise an exception. To sum up, > either you optimize away the final assignment to D or you raise an > exception, i.e. D cannot contain a random value. OK, so a division by zero is not invoking undefined behavior but is well-defined and traps. And the idea is that -fnon-call-exceptions alone carries this over to middle-end semantics? (I don't think it does that at the moment, with or without the rev. in question)