From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,76c4b4e5caa63729 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-11-27 17:29:03 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!newsfeed1.earthlink.net!newsfeed.earthlink.net!newsmaster1.prod.itd.earthlink.net!newsread2.prod.itd.earthlink.net.POSTED!not-for-mail Message-ID: <3C043DC5.96DF5978@acm.org> From: Jeffrey Carter X-Mailer: Mozilla 4.7 [en] (Win98; U) X-Accept-Language: en MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: Getting started with Ada: Runtime exceptions? References: <3e076d85.0111271647.338f33d@posting.google.com> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Date: Wed, 28 Nov 2001 01:29:05 GMT NNTP-Posting-Host: 209.86.211.195 X-Complaints-To: abuse@earthlink.net X-Trace: newsread2.prod.itd.earthlink.net 1006910945 209.86.211.195 (Tue, 27 Nov 2001 17:29:05 PST) NNTP-Posting-Date: Tue, 27 Nov 2001 17:29:05 PST Organization: EarthLink Inc. -- http://www.EarthLink.net X-Received-Date: Tue, 27 Nov 2001 17:29:02 PST (newsmaster1.prod.itd.earthlink.net) Xref: archiver1.google.com comp.lang.ada:17075 Date: 2001-11-28T01:29:05+00:00 List-Id: Dick Rumsfeld wrote: > > Hello all, > I've just today started to learn Ada. In Section 1.4 of the online > tutorial I am learning from, > http://www.adahome.com/Tutorials/Lovelace/s1sf.htm > it is stated that the below program, when run, will print 2^n for each > n starting with n=0, until an overflow occurs, at which time the > program will automatically halt with a message stating an exception > occured. Well, when I compiled and ran the below program using > "gnatmake" (which I've just downloaded for my Linux distribution), it > gives the following output: > > 1 > 2 > 4 > 8 > [...output elided...] > 536870912 > 1073741824 > -2147483648 > 0 > 0 > 0 > ... A dirty little secret about GNAT is that integer overflow checking is OFF by default, as you discovered. If you had read the Secret Documentation for GNAT, you'd know that you turn it ON with the switch -gnato in which case your program should output ... 512 1024 2048 4096 8192 16384 32768 65536 131072 262144 524288 1048576 2097152 4194304 8388608 16777216 33554432 67108864 134217728 268435456 536870912 1073741824 raised CONSTRAINT_ERROR : compute.adb:9 which is much less C-like than your experience. I hope this foible of GNAT will not put you off Ada. This default was chosen because, IIRC, in GNAT's early days integer overflow checking was very expensive on some platforms. I don't know if that's still the case, but modern processors are so much faster than those of GNAT's early days that there are probably few situations in which it makes a difference, so this is probably still the default only for compatibility reasons. I certainly always turn overflow checking on when using GNAT, and have never found it too slow. -- Jeff Carter "I unclog my nose towards you." Monty Python & the Holy Grail