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!feeder.eternal-september.org!aioe.org!.POSTED!not-for-mail From: "Dmitry A. Kazakov" Newsgroups: comp.lang.ada Subject: Re: ADA.STRINGS.INDEX_ERROR : a-strunb.adb:782 Date: Mon, 15 Jan 2018 09:29:39 +0100 Organization: Aioe.org NNTP Server Message-ID: References: NNTP-Posting-Host: MyFhHs417jM9AgzRpXn7yg.user.gioia.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Complaints-To: abuse@aioe.org User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.5.2 X-Notice: Filtered by postfilter v. 0.8.2 Content-Language: en-US Xref: reader02.eternal-september.org comp.lang.ada:49902 Date: 2018-01-15T09:29:39+01:00 List-Id: On 15/01/2018 02:18, Mehdi Saada wrote: > This if statement exactly, seems to raise > "ADA.STRINGS.INDEX_ERROR : a-strunb.adb:782"(No indication of line, so I can't know more). There is a list of funny numbers following the exception message. Pass that list to addr2line --exe= That will give you the stack trace. > What does this exception means ? You can see there's no string type variable to be accessed, here. > CHAINE is of UNBOUNDED_STRING type. LA_PILE is a stack of characters, EMPILER means "putting on the stack's top" in french. > > if IS_BASIC(ELEMENT(CHAINE,IND)) then > EMPILER(LA_PILE,ELEMENT(CHAINE,IND)); > else DELETE(CHAINE, IND,IND); > end if; > > It's enclosed in: > for Ind in 1..Length(CHAINE) loop > begin > if IS_BASIC(ELEMENT(CHAINE,IND)) then > EMPILER(LA_PILE,ELEMENT(CHAINE,IND)); > else DELETE(CHAINE, IND,IND); > end if; > end; > end loop; When deleting elements of a list by position the loop must run positions in reverse: for Ind in reverse 1 .. Length (CHAINE) loop ... delete at Ind ... end loop; That will keep the positions straight. Position /= index, BTW. However, deleting characters from a string almost never has sense. You probably should reconsider the algorithm. -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de