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!news.eternal-september.org!mx02.eternal-september.org!feeder.eternal-september.org!nntp-feed.chiark.greenend.org.uk!ewrotcd!reality.xs3.de!news.jacob-sparre.dk!loke.jacob-sparre.dk!pnx.dk!.POSTED!not-for-mail From: Tero Koskinen Newsgroups: comp.lang.ada Subject: Re: Ada.Strings.Fixed.Count raises Storage_Error Date: Thu, 12 May 2016 18:22:08 +0300 Organization: JSA Research & Innovation Message-ID: References: <57346ac8$0$4570$426a74cc@news.free.fr> NNTP-Posting-Host: 178-55-127-95.bb.dnainternet.fi Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Trace: loke.gir.dk 1463066519 21509 178.55.127.95 (12 May 2016 15:21:59 GMT) X-Complaints-To: news@jacob-sparre.dk NNTP-Posting-Date: Thu, 12 May 2016 15:21:59 +0000 (UTC) User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.7.2 In-Reply-To: <57346ac8$0$4570$426a74cc@news.free.fr> Xref: news.eternal-september.org comp.lang.ada:30390 Date: 2016-05-12T18:22:08+03:00 List-Id: Hi, 12.5.2016, 14.36, Xavier Petit wrote: > Hello, I would like to know if it is normal or a known bug. > > function Count > (Source : String; > Pattern : String; > Mapping : Maps.Character_Mapping := Maps.Identity) return Natural; > > When Source'Last = Positive'Last and Pattern'Length = 1, I get > Storage_Error, it seems this is because the checks are suppressed in > this GNAT runtime function ? So with checks it would result a > Constraint_Error ? ... > > Here the code : > > with Ada.Strings.Fixed, Ada.Integer_Text_IO; > use Ada.Strings.Fixed, Ada.Integer_Text_IO; > > procedure Test_Count is > S : constant String (Positive'Last - 2 .. Positive'Last) := "Ada"; > begin > Put (Count (Source => S, Pattern => "AA")); > Put (Count (Source => S (S'First .. S'Last - 1), Pattern => "A")); > Put (Count (Source => S, Pattern => "A")); > end; > > Output on gnat-gcc 5.3.1 : > > 0 1 > > raised STORAGE_ERROR : stack overflow or erroneous memory access When compiled with Janus/Ada the output is following: C:\Work\xavier-fixed-count\obj> test_cou 0 1 1 C:\Work\xavier-fixed-count\obj> I would say that Janus/Ada is correct here and you have found a bug from GNAT. > > Thanks by advance > Yours, Tero