PATCH: Bad signed int to long long conversion
tg at gmplib.org
Thu Feb 9 18:17:17 CET 2012
Vincent Lefevre <vincent at vinc17.net> writes:
On 2012-02-09 17:01:45 +0100, Torbjorn Granlund wrote:
> Strictly speaking, I don't think things like (unsigned long)(MIN_LONG)
> is well-defined C.
It is well-defined:
184.108.40.206 Signed and unsigned integers
1 When a value with integer type is converted to another integer
type other than _Bool, if the value can be represented by the
new type, it is unchanged.
2 Otherwise, if the new type is unsigned, the value is converted
by repeatedly adding or subtracting one more than the maximum
value that can be represented in the new type until the value
is in the range of the new type.60)
Rule 2 surely covers this. Is this from C99? IIRC, this was not
well-defined in C89. Am I wrong?
More information about the gmp-bugs