Do C++ signed types have modulo semantics?
Gabriel Dos Reis
gdr@integrable-solutions.net
Tue Jun 28 15:55:00 GMT 2005
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
More information about the Gcc
mailing list