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,WEIRD_PORT autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,4c1892715ffb825c X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2002-06-02 05:43:52 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!newsfeed.berkeley.edu!news-hog.berkeley.edu!ucberkeley!newshub.sdsu.edu!west.cox.net!cox.net!news-east.rr.com!chnws02.ne.ipsvc.net!cyclone.ne.ipsvc.net!24.128.8.70!typhoon.ne.ipsvc.net.POSTED!not-for-mail From: "Jeffrey Creem" Newsgroups: comp.lang.ada References: <3CF9FB01.2070101@yahoo.com> <3CF9FBC1.7040701@yahoo.com> Subject: Re: Exceptions in GNAT X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2600.0000 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000 Message-ID: <9moK8.17320$Oj7.4886808@typhoon.ne.ipsvc.net> Date: Sun, 02 Jun 2002 12:39:33 GMT NNTP-Posting-Host: 66.31.5.146 X-Complaints-To: abuse@attbi.com X-Trace: typhoon.ne.ipsvc.net 1023021573 66.31.5.146 (Sun, 02 Jun 2002 08:39:33 EDT) NNTP-Posting-Date: Sun, 02 Jun 2002 08:39:33 EDT Organization: ATT Broadband Xref: archiver1.google.com comp.lang.ada:25197 Date: 2002-06-02T12:39:33+00:00 List-Id: The only exceptions you are getting are coming from the IO (Data_Error) when you enter integers larger then the largest integer. There is explicit code hiding in the body of text_IO.integer_IOt that is finding that your data is not appropriate for the type. What you want is integer overflow checking enabled. GNAT/GCC require a few options to get LRM compliant checks "On". GNAT does have many checks enabled by default bit integer overflow is not one of them. Check the google history of this group for the "best" recommended options. When in the heat of development, I usually use something like : gnatmake -g -gnato -fstack-check my_program_name You need to read through the GNAT users guide to get the rest of the options for your other questions (since I am not entirely clear how many of these questions are part of the assignment and how many are personal knowledge requests). "David Rasmussen" wrote in message news:3CF9FBC1.7040701@yahoo.com... > David Rasmussen wrote: > > I am learning Ada, and in one exercise I am told to find out how large > > and integer I can use on my system, before it overflows. The exercise > > just tells me to add two larger and larger numbers and see when an > > exception occurs. I have just compiled my program with gnatmake with no > > options, and I am using gcc 3.1 . When the numbers get large enough, the > > result is just a negative number because of wrap-around. Shouldn't I get > > an exception, unless I turn it off? How do I compile for with most > > checks for debug builds, and how do I compile with everything turned off > > for performance intensive release builds? > > > > /David > > > > D'oh.... This is weird: > > Enter two integers: 2100000000 0 > The sum is 2100000000 > david@amadeus-T23:~/src/Ada/Ex21$ ./sum > Enter two integers: 2200000000 0 > > > raised ADA.IO_EXCEPTIONS.DATA_ERROR : a-tiinio.adb:91 instantiated at > a-inteio.ads:20 > david@amadeus-T23:~/src/Ada/Ex21$ ./sum > Enter two integers: 2147483648 0 > > > raised ADA.IO_EXCEPTIONS.DATA_ERROR : a-tiinio.adb:91 instantiated at > a-inteio.ads:20 > david@amadeus-T23:~/src/Ada/Ex21$ ./sum > Enter two integers: 2147483647 0 > The sum is 2147483647 > david@amadeus-T23:~/src/Ada/Ex21$ ./sum > Enter two integers: 2147483647 1 > The sum is-2147483648 > david@amadeus-T23:~/src/Ada/Ex21$ ./sum > Enter two integers: 2147483647 2 > The sum is-2147483647 > david@amadeus-T23:~/src/Ada/Ex21$ > > Sometimes there's an exception, and sometimes there isn't... What's > happening?? > > /David >