http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46619
--- Comment #16 from Eskil Steenberg <eskil at obsession dot se> 2010-11-23 22:31:14 UTC --- Hi again! > http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46619 > > --- Comment #15 from Andrew Pinski <pinskia at gcc dot gnu.org> 2010-11-23 > 22:09:44 UTC --- >>Not true. it is not undefined, it is implementation specific. > > Huh? Why do you think that is true? The C standard is explicit when it > comes > to signed integer overflow is undefined behavior. In fact when talking > about > an undefined behavior at the very beginning of the standard, it lists it. I see this now, i was looking at this: -------------------- 3.2.1.2 Signed and unsigned integers When an unsigned integer is converted to another integral type, if the value can be represented by the new type, its value is unchanged. When a signed integer is converted to an unsigned integer with equal or greater size, if the value of the signed integer is nonnegative, its value is unchanged. Otherwise: if the unsigned integer has greater size, the signed integer is first promoted to the signed integer corresponding to the unsigned integer; the value is converted to unsigned by adding to it one greater than the largest number that can be represented in the unsigned integer type. /22/ When an integer is demoted to an unsigned integer with smaller size, the result is the nonnegative remainder on division by the number one greater than the largest unsigned number that can be represented in the type with smaller size. When an integer is demoted to a signed integer with smaller size, or an unsigned integer is converted to its corresponding signed integer, if the value cannot be represented the result is implementation-defined. ----------------------- Still one could argue that this text: Undefined behavior --- behavior, upon use of a nonportable or erroneous program construct, of erroneous data, or of indeterminately-valued objects, for which the Standard imposes no requirements. Permissible undefined behavior ranges from ignoring the situation completely with unpredictable results, to behaving during translation or program execution in a documented manner characteristic of the environment (with or without the issuance of a diagnostic message), to terminating a translation or execution (with the issuance of a diagnostic message). ...Allows the undefined behavior, to either doing something (witch it does), doing nothing, or terminating (the compilation or execution). It does not allow the implementation to change the behavior of things defined in the spec. Cheers E