This is the mail archive of the
java@gcc.gnu.org
mailing list for the Java project.
Re: what optimizations are invalid in java?
- From: dewar at gnat dot com (Robert Dewar)
- To: aph at cambridge dot redhat dot com, jh at suse dot cz
- Cc: gcc at gcc dot gnu dot org, java at gcc dot gnu dot org, tromey at redhat dot com
- Date: Wed, 13 Mar 2002 09:55:57 -0500 (EST)
- Subject: Re: what optimizations are invalid in java?
<<Only divide by zero. Basically, Java does whatever SPARC UNIX
happened to do at the time. This is not, I suspect, a coincidence...
>>
I think that's probably unfair. Division by zero is obviously reasonable
to consider as an error, one cannot imagine any program expecting something
useful from divide by zero (though I hesitate to say such things are the
adamant support for the utility of self-initializations :-)
But when it comes to artithmetic overflow, there are two issues to consider
1. efficiency, testing for overflow in all signed arithmetic operations is
not free.
2. expected functionality. many C programmers expect and count on wrap around
semantics for signed arithmetic even though it is not defined.
In Java, signed arithmetic had to be made always wrap around, or always
checking. Now I would have gone for always checked, but I understand the
arguments for wrap around.