Re: Divide by zero works on ia64!!!

From: James E Wilson <wilson_at_tuliptree.org>
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
issue.

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 majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
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