https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93013

Segher Boessenkool <segher at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|---                         |INVALID

--- Comment #6 from Segher Boessenkool <segher at gcc dot gnu.org> ---
Unspecified, yes.  So the code we generate is just fine.

Note that we could optimise away the whole y == 0 arm as well, since if we
execute that we have caused UB in the modulo before that already.  But GCC
is not so aggressive in exploiting UB, and that is probably a good thing.

Reordering the code so that the % is only executed if y is not -1 makes the
code do what you want.

Closing as invalid.  Thanks for the report.

Reply via email to