divide overflow

Ulrich Drepper drepper@cygnus.com
Thu May 20 14:30:00 GMT 1999


Jason Schonberg <schon@mips.com> writes:

> The following code runs on a Sparc Solaris 2.6 system but fails with a "Floating 
> exception (core dumped)" on an X86 Redhat 6.0 system.
> 
> Both systems were using egcs-1.1.2
> 
> _____
> #include <limits.h>
> 
> int main()
> {
>  long int A, B, C;
>  A = INT_MIN;
>  B = -1;
>  C = A/B;
> }
> _____

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.

-- 
---------------.      drepper at gnu.org  ,-.   1325 Chesapeake Terrace
Ulrich Drepper  \    ,-------------------'   \  Sunnyvale, CA 94089 USA
Cygnus Solutions `--' drepper at cygnus.com   `------------------------


More information about the Gcc-bugs mailing list