Re: Divide by zero works on ia64!!!

From: James E Wilson <>
Date: 2005-05-12 04:36:13
On Mon, 2005-05-09 at 13:37, Gerald Pfeifer wrote:
> As Andreas pointed out, this code invokes undefined behavior.  Undefined
> here means that the result of an operation is not defined by the language
> standard, and 0 is a valid result when invoking an undefined operation.

It is undefined in C and C++, but what about other stricter languages
like Java and Ada?  I don't have language standards for either of them,
but I believe they both require exceptions here.  Then there is the
question of Fortran, which may also have something to say about this

Also, while C doesn't require an exception, it is expected behaviour for
a POSIX system, and other gcc ports make sure we get an exception.  The
MIPS gcc port for instance emits a conditional trap instruction, because
the MIPS integer divide instruction does not trap.  The IA-64 gcc port
could do likewise.

I'd call this an oversight, a quality of implementation problem for C, a
probable bug for Java and Ada, and worthy of a gcc bugzilla bug report
so that we don't forget about it.

To unsubscribe from this list: send the line "unsubscribe linux-ia64" in
the body of a message to
More majordomo info at
Received on Wed May 11 14:38:06 2005

This archive was generated by hypermail 2.1.8 : 2005-08-02 09:20:38 EST