divide overflow
Jason Schonberg
schon@mips.com
Thu May 20 15:21:00 GMT 1999
>Jason Schonberg <schon@mips.com> writes:
>> _____
>> #include <limits.h>
>>
>> int main()
>> {
>> long int A, B, C;
>> A = INT_MIN;
>> B = -1;
>> C = A/B;
>> }
>> _____
Ulrich Drepper writes:
> This is known and the result is correct. The hardware simply signals
> that an invalid operation is performed since the result cannot be
> represented. If other platforms do not check this and you depend on
> this the program is simply not portable.
I understand that in two's compliment notation, the lowest negative integer has
an absolute value one larger than the maximum positive number. Thus I would
expect an exception.
What puzzles me more is that the following code _DOES NOT_ display similar
behavior. (again egcs 1.1.2 - X86 Linux Redhat 6.0)
#include <limits.h>
int main()
{
long int A, B, C;
A = INT_MIN;
B = -1;
C = A*B;
}
--
Jason Schonberg
schon@mips.com
More information about the Gcc-bugs
mailing list