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,ae9506fd4dcf7090 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2002-10-23 08:25:43 PST Newsgroups: comp.lang.ada Path: archiver1.google.com!news2.google.com!news1.google.com!newsfeed.stanford.edu!bloom-beacon.mit.edu!news-out.cwix.com!newsfeed.cwix.com!nntp.abs.net!uunet!dca.uu.net!ash.uu.net!world!news From: Robert A Duff Subject: Re: Concatenation and Characters User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.2 Sender: news@world.std.com (Mr Usenet Himself) Message-ID: Date: Wed, 23 Oct 2002 15:24:31 GMT Content-Type: text/plain; charset=us-ascii References: <44hp9.807$_u6.205@nwrddc01.gnilink.net> <3DA5AE5F.3030902@attbi.com> <3DB03EF1.EE771923@mmm.com> <3DB43EB0.AAF4B38C@mmm.com> <3DB44B9C.80007@worldnet.att.net> <3DB466CB.7CE0BC59@mmm.com> <3DB4AD20.4070109@acm.org> <3DB59D75.20609 <3DB60342.3020104@acm.org> NNTP-Posting-Host: shell01.theworld.com Mime-Version: 1.0 Organization: The World Public Access UNIX, Brookline, MA Xref: archiver1.google.com comp.lang.ada:30079 Date: 2002-10-23T15:24:31+00:00 List-Id: Jeffrey Carter writes: > Robert A Duff wrote: > > The Ada 83 optimizer could reason as follows: > > I is of subtype Positive. > > So either the value of I is in Positive, or else I is uninitialized. > > If I is in Positive, we can leave out the array bounds check, > > because the index subtype of String is also Positive. > > If I is uninitialized, we can leave out the check because > > the program execution will be erroneous (unpredictable). > > Well, if you say this was so, I guess it probably was so. Not true. I wasn't thinking clearly. For the example given, you are correct that a bounds check is needed, at least on the upper bound. I suppose the compiler could optimize away the check on the lower bound. In any case, although I put my foot in my mount about *that* example, I think my more general point is correct: there are cases where an Ada 83 compiler could optimize away checks (based on the erroneousness of uninit vars), where an Ada 95 compiler cannot (or at least has to prove more). >... Having used > Ada 83 for over a decade, I never encountered a compiler that wouldn't > check that I was in the range of S (not the index subtype of > String). Clearly the range of S could be anything from null through > Positive. I'm surprised that Ada 83 would allow a variable to index an > array of unknown range without a bounds check. - Bob