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!newsfeed.fsmpi.rwth-aachen.de!newsfeed.straub-nv.de!proxad.net!feeder1-2.proxad.net!cleanfeed2-b.proxad.net!nnrp3-1.free.fr!not-for-mail Newsgroups: comp.lang.ada X-Mozilla-News-Host: news://news.free.fr:119 From: Xavier Petit Subject: Ada.Strings.Fixed.Count raises Storage_Error Date: Thu, 12 May 2016 13:36:40 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Icedove/38.6.0 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Message-ID: <57346ac8$0$4570$426a74cc@news.free.fr> Organization: Guest of ProXad - France NNTP-Posting-Date: 12 May 2016 13:36:40 CEST NNTP-Posting-Host: 78.217.21.11 X-Trace: 1463053000 news-2.free.fr 4570 78.217.21.11:59050 X-Complaints-To: abuse@proxad.net Xref: news.eternal-september.org comp.lang.ada:30386 Date: 2016-05-12T13:36:40+02:00 List-Id: 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 ? Internally, the exit condition is tested after the index incrementation, so in this specific case the “Ind” index tries to store Positive'Last + 1. I think. 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 Thanks by advance -- Xavier Petit