Re: Arithmetic overflow checking
"Nasser M. Abbasi" wrote:
rop rop wrote:
If I want to have arithmetic-overflow checking in all parts of an
application,
what is the most practical, simple, efficient way to achieve this?
Id like to clutter the code as little a possible...
Is there any way to instruct the JVM to include it?
What? You mean you guys do not have this in Java??
It is a compiler option in Ada GNAT/gcc compiler:
http://gcc.gnu.org/onlinedocs/gcc-4.3.5/gnat_ugn_unw/Run_002dTime-Che...
"`-gnato'
Enables overflow checking for integer operations. This causes
GNAT to generate slower and larger executable programs by adding
code to check for overflow (resulting in raising Constraint_Error as
required by standard Ada semantics)."
This is something that should be there in Java.
Ada was mentioned upthread as a language with the feature. Not only
we guys, but no one has this in Java, as the many posts upthread have
made quite clear. In fact, the Java language specification
specifically excludes trapping overflow in integer operations. As was
mentioned upthread by several folks. Lots of posters have expressed
the opinion that the feature should be present in some form in Java.
The discussion has now progressed to the form such a feature could
take without breaking Java and all the Java programs out there. Some
of the suggestions seem to be viable.
--
Lew