comp.lang.ada
 help / color / mirror / Atom feed
From: Victor Porton <porton@narod.ru>
Subject: Re: Ada.Strings.Fixed.Count raises Storage_Error
Date: Mon, 27 Jun 2016 00:18:47 +0300
Date: 2016-06-27T00:18:47+03:00	[thread overview]
Message-ID: <nkpgrl$1r41$1@gioia.aioe.org> (raw)
In-Reply-To: nh2ugj$k6r$1@dont-email.me

GNAT 6.1.1 on Debian Linux "testing":

$ ./test_count 
          0          1

raised STORAGE_ERROR : stack overflow or erroneous memory access

Let's decide who of us will report the bug, so that the report won't happen 
to be duplicate?

Georg Bauhaus wrote:
> On 12.05.16 13:36, Xavier Petit wrote:
> 
>> 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
> 
> Compiling such that the RTS is recompiled will result in
> 
> raised CONSTRAINT_ERROR : a-strsea.adb:102 overflow check failed
> 
> The message points at a line in the implementation of
> Ada.Strings.Search.Count, for the third of the calls. It reads
> 
>       Ind := Ind + 1;
> 
> where Ind looks seems to be go along with the Index of your S,
> IINM. Effectively (PL1 = Pattern'Length - 1 being 0), then loop
> there boils down to this:
> 
>     while Ind <= Source'Last loop
>        if Pattern = Source (Ind .. Ind) then
>           ...
>        else
>           Ind := Ind + 1;
>        end if;
>     end loop;
> 
> And this would explains the overflow.
> 
> Just the slip-up that Ada subtypes were designed to help prevent?
> 
> 
-- 
Victor Porton - http://portonvictor.org


  reply	other threads:[~2016-06-26 21:18 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
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