This is the mail archive of the java@gcc.gnu.org mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]