Path: csiph.com!x330-a1.tempe.blueboxinc.net!newsfeed.hal-mli.net!feeder3.hal-mli.net!news.glorb.com!postnews.google.com!e20g2000prf.googlegroups.com!not-for-mail From: lewbloch Newsgroups: comp.lang.java.programmer Subject: Re: Arithmetic overflow checking Date: Sat, 9 Jul 2011 12:16:15 -0700 (PDT) Organization: http://groups.google.com Lines: 36 Message-ID: References: <015aeb15-57db-48ab-9cd4-77f8448b632f@w24g2000yqw.googlegroups.com> NNTP-Posting-Host: 108.89.33.208 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: posting.google.com 1310242801 29495 127.0.0.1 (9 Jul 2011 20:20:01 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Sat, 9 Jul 2011 20:20:01 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: e20g2000prf.googlegroups.com; posting-host=108.89.33.208; posting-account=CP-lKQoAAAAGtB5diOuGlDQk0jIwmH0T User-Agent: G2/1.0 X-Google-Web-Client: true X-Google-Header-Order: HNKRUAELSC X-HTTP-UserAgent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/535.1 (KHTML, like Gecko) Chrome/13.0.782.41 Safari/535.1,gzip(gfe) Xref: x330-a1.tempe.blueboxinc.net comp.lang.java.programmer:6019 "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' > =A0 =A0 =A0Enables 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