This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Do C++ signed types have modulo semantics?
- From: Andrew Pinski <pinskia at physics dot uc dot edu>
- To: Gabriel Dos Reis <gdr at integrable-solutions dot net>
- Cc: Nathan Sidwell <nathan at codesourcery dot com>, gcc mailing list <gcc at gcc dot gnu dot org>
- Date: Tue, 28 Jun 2005 10:04:54 -0400
- Subject: Re: Do C++ signed types have modulo semantics?
- References: <OF0E4366CA.5D54868B-ON4325702E.0036D351-4325702E.003973C5@il.ibm.com> <m3k6keeibo.fsf@uniton.integrable-solutions.net> <42C15026.7070304@codesourcery.com> <m3r7emd1m0.fsf@uniton.integrable-solutions.net>
On Jun 28, 2005, at 9:58 AM, Gabriel Dos Reis wrote:
Notice that in your rendition you're assuming that you can convert any
unsigned value > INT_MAX to a int without invoking undefined behaviour.
If you read Nathan's mail correctly, the cast is implementation defined
and not undefined behavior so your argument does not work.
Quote from Nathan's mail (the emphases are not mine but Nathan's which
means he wanted
to you to read that part and not say it was undefined behavior):
(provided we're on the standard 2's complement machine where the
mapping between negative ints and unsigned is *implementation defined*
to be the sane mapping, which I might point out you've already assumed
in the wrap_sum I quoted).
-- Pinski