From: Xavier Petit <xpetit@becoast.fr>
Subject: Ada.Strings.Fixed.Count raises Storage_Error
Date: Thu, 12 May 2016 13:36:40 +0200
Date: 2016-05-12T13:36:40+02:00 [thread overview]
Message-ID: <57346ac8$0$4570$426a74cc@news.free.fr> (raw)
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
next reply other threads:[~2016-05-12 11:36 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-05-12 11:36 Xavier Petit [this message]
2016-05-12 15:22 ` Ada.Strings.Fixed.Count raises Storage_Error Tero Koskinen
2016-05-12 22:05 ` Georg Bauhaus
2016-06-26 21:18 ` Victor Porton
2016-06-26 23:23 ` rieachus
2016-06-27 0:21 ` Jeffrey R. Carter
2016-06-27 4:00 ` rieachus
2016-06-27 0:51 ` Xavier Petit
2016-06-27 4:48 ` rieachus
2016-06-28 18:25 ` Xavier Petit
2016-06-29 18:49 ` Niklas Holsti
2016-06-29 19:40 ` Jeffrey R. Carter
2016-06-29 19:57 ` Dmitry A. Kazakov
2016-07-01 11:48 ` rieachus
2016-07-01 13:08 ` Dmitry A. Kazakov
2016-06-27 8:29 ` Simon Wright
2016-06-27 8:41 ` Georg Bauhaus
2016-06-29 8:15 ` Niklas Holsti
2016-06-29 9:13 ` J-P. Rosen
2016-06-29 17:43 ` Niklas Holsti
2016-06-29 18:19 ` J-P. Rosen
2016-06-29 20:30 ` Robert A Duff
2016-06-30 5:38 ` Niklas Holsti
2016-07-01 10:40 ` rieachus
2016-07-01 10:55 ` J-P. Rosen
2016-07-01 12:17 ` rieachus
2016-07-01 12:55 ` G.B.
2016-06-27 12:52 ` Victor Porton
2016-05-12 22:56 ` Randy Brukardt
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox