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,8d472879e3f609e0 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-06-06 02:02:36 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!bloom-beacon.mit.edu!nycmny1-snh1.gtei.net!nycmny1-snf1.gtei.net!news.gtei.net!colt.net!kibo.news.demon.net!news.demon.co.uk!demon!not-for-mail From: Simon Wright Newsgroups: comp.lang.ada Subject: Re: Case sensitivity (was Re: no title) Date: 06 Jun 2003 10:01:56 +0100 Organization: Pushface Sender: simon@smaug Message-ID: References: <20619edc.0306021018.6ee4dd09@posting.google.com> <1054649187.11497@master.nyc.kbcfp.com> <20619edc.0306031034.6a2f5f25@posting.google.com> <1054666439.685312@master.nyc.kbcfp.com> <1054735867.264510@master.nyc.kbcfp.com> <1054748714.868159@master.nyc.kbcfp.com> NNTP-Posting-Host: pogner.demon.co.uk Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: news.demon.co.uk 1054890155 10346 62.49.19.209 (6 Jun 2003 09:02:35 GMT) X-Complaints-To: abuse@demon.net NNTP-Posting-Date: Fri, 6 Jun 2003 09:02:35 +0000 (UTC) User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.2.93 Xref: archiver1.google.com comp.lang.ada:38753 Date: 2003-06-06T10:01:56+01:00 List-Id: James Rogers writes: > When I place this snippet into a real program I do get a clean > compile. The program does generate an exception at run time on > the first loop iteration. > > with Ada.Text_Io; > use Ada.Text_Io; > procedure Badloop is > type Foo_Array is array (1 .. 10) of Integer; > My_Array : Foo_Array := (10, 9, 8, 7, 6, 5, 4, 3, 2, 1); > Current_Maximum : Integer := 1; > begin > for Index in My_Array'range loop > declare > Index : Integer := 27; > begin > if My_Array ( Index ) > Current_Maximum > then > Current_Maximum := My_Array ( Index ); > Index := Index; > end if; > end; > end loop; > Put_Line("Current_Maximum:" & Integer'Image(Current_Maximum)); > end Badloop; GNAT 3.16a says (-gnatwaL => all warnings except elaboration order): smaug[60]$ gnatmake -g -O2 -gnatwaL badloop gcc -c -g -O2 -gnatwaL badloop.adb badloop.adb:5:04: warning: "My_Array" is not modified, could be declared constant badloop.adb:12:24: warning: value not in range of subtype of "Standard.Integer" defined at line 4 badloop.adb:12:24: warning: "Constraint_Error" will be raised at run time badloop.adb:14:43: warning: value not in range of subtype of "Standard.Integer" defined at line 4 badloop.adb:14:43: warning: "Constraint_Error" will be raised at run time badloop.adb:15:19: warning: useless assignment of "Index" to itself gnatbind -x badloop.ali gnatlink badloop.ali -g smaug[61]$ ./badloop raised CONSTRAINT_ERROR : badloop.adb:12 range check failed without -gnatwaL, the first and last warnings are omitted.