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: Gabriel Dos Reis <gdr at integrable-solutions dot net>
- To: Michael Veksler <VEKSLER at il dot ibm dot com>
- Cc: gcc mailing list <gcc at gcc dot gnu dot org>, Nathan Sidwell <nathan at codesourcery dot com>, Andrew Pinski <pinskia at physics dot uc dot edu>
- Date: 28 Jun 2005 17:54:43 +0200
- Subject: Re: Do C++ signed types have modulo semantics?
- References: <OF8C53C77B.667A02DE-ON4325702E.00541FD7-4325702E.005534DD@il.ibm.com>
Michael Veksler <VEKSLER@il.ibm.com> writes:
| Gabriel Dos Reis wrote on 28/06/2005 17:12:43:
|
| > Andrew Pinski <pinskia@physics.uc.edu> writes:
| >
| > | 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.
| >
| > I stand corrected!
| >
|
| So what does gcc gives for (int) (MAX_INT+1U)?
It should give you INT_MIN. At least numeric_limits<int>::min is
implemented that way (suggested by RTH).
| This behavior seems to be undocumented (a documentation PR?).
Yes, we should document this. In general, implementation defined
aspects (and some of the undefined behaviour aspects) are missing
documentation for C++ -- JSM did some work for that for C.
-- Gaby