comp.lang.ada
 help / color / mirror / Atom feed
* Ada.Strings.Fixed.Count raises Storage_Error
@ 2016-05-12 11:36 Xavier Petit
  2016-05-12 15:22 ` Tero Koskinen
                   ` (2 more replies)
  0 siblings, 3 replies; 29+ messages in thread
From: Xavier Petit @ 2016-05-12 11:36 UTC (permalink / 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

^ permalink raw reply	[flat|nested] 29+ messages in thread

end of thread, other threads:[~2016-07-01 13:08 UTC | newest]

Thread overview: 29+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-05-12 11:36 Ada.Strings.Fixed.Count raises Storage_Error Xavier Petit
2016-05-12 15:22 ` 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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox