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


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

Re: CFG and libcall conflict for java



> >Does Java standard require the trap to happen?

Jim Wilson writes:
> Alex answered that one.  I knew about the divide by zero, but wasn't aware
> that this only mattered for integer divides, and that this was the only case.

(presumably Java defines floating point divide by zero to produce a
non-signalling NaN?)

Perhaps I'm tempted to go for a simple solution because I'm not as smart
as you. :-)

Since integer divide is the only case where a trap has to turn into a
throw, one solution would be to avoid the problem entirely:
generate code for the Java

	result = num / den;

(where num and den are integral)
as the equivalent of C++

	if (den) throw DivideByZero();
	result = num / den;

Yes, it slows down integer division, but it's easy to get right on
all platforms.  If the trap-into-throw mechanism works reliably on
some ports, then for those ports you could omit the test.


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