http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52661

--- Comment #14 from Jim Michaels <jmichae3 at yahoo dot com> 2012-03-22 
21:45:33 UTC ---
OK, given your argument, let's look at -32768 for a short.
it's just too big because 32768 is larger than the size of an int, so it's
considered unsigned, right?  wrong.  no warning message.

which is what I have been trying to say.  your argument doesn't hold water.
this value is within the proper size for an int.  it's the minimum number of an
int.


-32768 is the one value that is valid which doesn't fit most people's use of an
int, which is only the range -32767..32767.  that is NOT the full range of a
short.

I am not sure why you are rooting for the compiler's way of doing things, it's
broken.  I understand what you are saying, I also understand that assuming the
value is unsigned because it's on the edge is wrong.  how about an if
statement, like
if (-1==sign && 9223372036854775808==mantissa) {
    datum=mantissa*sign;
} else if (1==sign && 9223372036854775808==mantissa) {
    datum=mantissa;
} else if (-1==sign && mantissa > 9223372036854775808) {
    printf("error:....\n");
} else if (1==sign && mantissa > 9223372036854775808) {
    printf("error:....\n");
}

why not just use an unsigned long long to hold the mantissa and keep the sign
as a bool or store it as another number as +1 or -1, and do some sort of range
check to make sure the number input is valid?  there are multiple ways

Reply via email to