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=unavailable autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail From: Simon Wright Newsgroups: comp.lang.ada Subject: Re: strange length check error Date: Thu, 18 Jan 2018 11:12:30 +0000 Organization: A noiseless patient Spider Message-ID: References: <14a35359-150a-4aa6-b437-19c74381be4b@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: reader02.eternal-september.org; posting-host="c6073624b7b4e840cd7bd5c83256224e"; logging-data="28835"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+fTDIxY8nSBC4YMiDmNk+5wBUmyDKJyxo=" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.3 (darwin) Cancel-Lock: sha1:MaOKERaClVLvs4xdoSwUEDvT3lY= sha1:f/9xzeXqhXShMwaK5c/tIsDFK+U= Xref: reader02.eternal-september.org comp.lang.ada:49972 Date: 2018-01-18T11:12:30+00:00 List-Id: "Jeffrey R. Carter" writes: > On 01/17/2018 02:41 PM, Simon Wright wrote: >> >> return >> (LENGTH(LEFT) + 1, >> LEFT.DATA(1..LENGTH(LEFT)) >> & RIGHT >> & LEFT.DATA((LENGTH(LEFT) + 1)..MAX_LENGTH)); > > I think the last part should be Left.Data (Left.Length + 1 > .. Max_Length - 1) or (Left.Length + 2 .. Max_Length). I guess it > doesn't matter what you put in those unused positions; you could also > have (Left.Length + 2 .. Max_Length => <>). Should have been (Left.Length + 2 .. Max_Length). That'll teach me not to post code without testing it .. > I'd probably have written > > Result : Bounded_String; > begin -- "&" > Result.Length := Left.Length + 1; > Result.Data (1 .. Result.Length) := Left (1 .. Left.Length) & Right; > > return Result; There was a check in the original that the input wasn't already at its max length. That aside, agreed.