From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.5-pre1 (2020-06-20) on ip-172-31-74-118.ec2.internal X-Spam-Level: X-Spam-Status: No, score=-1.9 required=3.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.5-pre1 Date: 7 Sep 93 21:56:53 GMT From: eachus@mitre-bedford.arpa (Robert I. Eachus) Subject: Re: How to assign STRINGs? Message-ID: List-Id: In article <1993Sep3.181825.920@cfmu.eurocontrol.be> stef@cfmu.eurocontrol.be ( Stef Van Vlierberghe) writes: Newsgroups: comp.lang.ada Path: linus.mitre.org!linus!agate!doc.ic.ac.uk!uknet!mcsun!ub4b!cfmu!news From: stef@cfmu.eurocontrol.be (Stef Van Vlierberghe) Sender: news@cfmu.eurocontrol.be (News account) Date: Fri, 3 Sep 93 18:18:25 GMT References: <25gmc2$3cf@neomimsy.cs.umd.edu> Nntp-Posting-Host: cfmu Organization: Eurocontrol - Central Flow Management Unit Lines: 30 In article eachus@spectre.mitre.org (Robert I. Eachus) writes: > Nice going Bob, but you were a bit over-focused on style I guess, > I would like to return Better_Ideas on this one : > String'(In_Str_Len+1..Out_Str'LENGTH => Pad_Char); ^^ > or you get a CONSTRAINT_ERROR. Mea culpa. > Hey, a new species of bug : off by 2 ! :-) Nope! Old bug species. Incorrect signs from double negation. I originally wrote In_Str_Len..Out_Str'LENGTH-1. (The catenation wipes the actual indexes, all that matters is the length.) But I moved the correction to the first index as less confusing, and the usually helpful SunAda compiler failed to do the symbolic arithmetic to eliminate the run-time check. (Not a compliant, since it catches most of these cases.) Next time I post something like this I'll have to test it, not just compile it. -- Robert I. Eachus with Standard_Disclaimer; use Standard_Disclaimer; function Message (Text: in Clever_Ideas) return Better_Ideas is...