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: Wed, 17 Jan 2018 09:23:44 +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="a024929726141132c88b6670cd864061"; logging-data="17205"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX186pf8BpdTJIucjcKwjw1KdJpqh7pdiDXo=" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.3 (darwin) Cancel-Lock: sha1:Siv77lOOmXVRpfBHvnXUwudiBEE= sha1:BK4nRZSWcot58W4bnZeS+1iWiY0= Xref: reader02.eternal-september.org comp.lang.ada:49951 Date: 2018-01-17T09:23:44+00:00 List-Id: Anh Vo writes: > On Tuesday, January 16, 2018 at 12:48:45 PM UTC-8, Mehdi Saada wrote: >> This : Put(Ch_Bounded1 & ' ' ); >> Calls on that: >> function "&" >> (Left : in Bounded_String; >> Right : in Character) >> return Bounded_String >> is >> begin >> if LENGTH(LEFT) + 1 > MAX_LENGTH then >> raise LENGTH_ERROR with "ERROR '&': LEFT.LENGTH := " & NATURAL'IMAGE(LENGTH(LEFT)) & " + 1 > MAX_LENGTH"; >> else >> @@@ return (LENGTH(LEFT) + 1, LEFT.DATA(1..LENGTH(LEFT)) & RIGHT); >> end if; >> end "&"; >> >> The line with @@@ raises this: >> raised CONSTRAINT_ERROR : p_bounded_g-p_new_bounded_g.adb:34 length check failed >> The value of CH_BOUNDED1 at that moment is "pour tester le debut", its length is 21, and MAX_LENGTH est 80. > > What is Bounded_String? I agree. It's not the one from the standard library ((a) it's different, (b) the standard library doesn't use this ugly, hard to read, identifiers-in-upper-case style). This shows why claims that you never need to use the debugger when you write in Ada are wrong. "What, never?" "Well,hardly ever."