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,2c52e9e46bd47415 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-06-03 08:01:05 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news.ems.psu.edu!news.cis.ohio-state.edu!news.maxwell.syr.edu!news.airnews.net!cabal12.airnews.net!usenet From: "John R. Strohm" Newsgroups: comp.lang.ada Subject: Re: FW: Ada 200X Date: Tue, 3 Jun 2003 09:55:48 -0500 Organization: Airnews.net! at Internet America Message-ID: References: Abuse-Reports-To: abuse at airmail.net to report improper postings NNTP-Proxy-Relay: library2.airnews.net NNTP-Posting-Time: Tue, 03 Jun 2003 09:59:50 -0500 (CDT) NNTP-Posting-Host: !X(8(1k-X^`)#=L (Encoded at Airnews!) X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1106 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 Xref: archiver1.google.com comp.lang.ada:38494 Date: 2003-06-03T09:55:48-05:00 List-Id: "Preben Randhol" wrote in message news:slrnbdpdan.87p.randhol+abuse@kiuk0152.chembio.ntnu.no... > Erlo Haugen wrote: > > Wouldn't > > subtype day_number is natural range 1..31; > > type month_days is array (day_number) of some_other_type; > > > > eliminate the boundschecking?? > > Not sure what you mean here. > > procedure testing is > subtype day_number is natural range 1..31; > type month_days is array (day_number) of Integer; > Mai : month_days; > begin > Mai (32) := 1; > end testing; > > gnatmake testing.adb > gnatgcc -c testing.adb > testing.adb:6:09: warning: value not in range of type "day_number" > defined at line 2 > testing.adb:6:09: warning: "constraint_error" will be raised at run time > gnatbind -x testing.ali > gnatlink testing.ali > > > ./testing > > raised CONSTRAINT_ERROR : testing.adb:6 What he meant is that the naive generated code would be if 32 <= 31 then Mai(32) := 1; else raise constraint_error; end if; but then the compiler would notice that 32 <= 31 is a static expression, evaluate it, and simplify the code to: raise constraint_error;