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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jakub at gcc dot gnu.org

--- Comment #5 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Both C11 (and later) and C++14 (and later) say:
if the quotient a/b is representable in the type of the result, (a/b)*b + a%b
is equal to a; otherwise, the behavior of both a/b and a%b is undefined."
and as INT_MIN/-1 is not representable in int, INT_MIN%-1 is UB.
In C++14 it has been changed through CWG1450 which was a DR, so that the change
applies to earlier C++ standards too.  Not really sure if the C change applies
to older standards too, otherwise it has been just underspecified there what
happens.

Reply via email to