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 17:33:49 PST Newsgroups: comp.lang.ada Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!canoe.uoregon.edu!arclight.uoregon.edu!news.tufts.edu!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: Thu, 24 Oct 2002 00:33: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> <3DB6F7A3.5060302@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:30085 Date: 2002-10-24T00:33:31+00:00 List-Id: Jeffrey Carter writes: > Robert A Duff wrote: > > 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. > > I would think even on the lower bound. The compiler knows nothing about > the bounds. The lower bound could be any value in Positive, so a > variable in Positive could easily be less than the lower bound just as > it could be greater than the upper bound. Yes, that's right. > > In any case, although I put my foot in my mount about *that* example, I ^^^^^ I can't even spell "mouth" right. :-( > > 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). > > If the variable has the same subtype as the index of the array object, I > can see this: > > procedure Op (S : in out String) is > I : Positive range S'range; > begin -- Op > S (I) := 'x'; > end Op; > > I is either in range or execution is erroneous. Yes (in Ada 83). > As I said in another post, a source of unexpected Constraint_Errors I > encountered in Ada 83 was from beginners assuming the lower bound of a > String parameter was one. A bounds check is required unless the index is > known to the compiler to be in the index range of the array object. > > I guess String was not a good type to use for an example. If it had been > > type Index is range 1 .. 100; > type Arr is array (Index) of Integer; > > I : Index; > A : Arr > ... > A (I) := 1; > > it would have been more obvious what we're talking about (I think). Yes. ;-) - Bob