comp.lang.ada
 help / color / mirror / Atom feed
From: Matthew Heaney <matthew_heaney@acm.org>
Subject: Re: How do functions return unbounded arrays?
Date: 1998/06/17
Date: 1998-06-17T00:00:00+00:00	[thread overview]
Message-ID: <m3lnqwyiaw.fsf@mheaney.ni.net> (raw)
In-Reply-To: 1998061518584100.OAA28557@ladder01.news.aol.com


johnherro@aol.com (John Herro) writes:

> > Are there Ada programs that cause a heap
> > overflow just by calling "&" in a long loop?
> 
> That question I can answer definitely.  The following program raises
> Storage_Error on my machine when compiled with Open Ada (an Ada 83
> compiler).  [program example snipped]

This is hardly a definate answer.  All it proves is that in one Ada 83
implementation, storage error gets raised.

We could probably make the storage error go away by declaring the string
in a nested block:

procedure Test is
begin
   for L in Long_Integer range
        10_000_000 .. 99_999_998 loop

      declare
         S : constant String :=
           Long_Integer'Image(L) &
           Long_Integer'Image(L + 1);
      begin
         null;
      end;

   end loop;
end Test;

I think the memory will get cleaned up when the frame terminates (that
is, every pass through the loop), and therefore storage_error won't
happen.






  reply	other threads:[~1998-06-17  0:00 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1998-06-14  0:00 How do functions return unbounded arrays? Markus Kuhn
1998-06-14  0:00 ` Robert A Duff
1998-06-15  0:00 ` John Herro
1998-06-17  0:00   ` Matthew Heaney [this message]
     [not found]   ` <35865075.9D7DCBD@cl.cam.ac.uk>
1998-06-17  0:00     ` Gavin Finnie
1998-06-17  0:00       ` Rod Chapman
1998-06-21  0:00         ` Robert Dewar
1998-06-21  0:00         ` Robert Dewar
1998-06-21  0:00       ` Robert Dewar
1998-06-17  0:00     ` Matthew Heaney
1998-06-21  0:00       ` Robert Dewar
1998-06-18  0:00     ` Mats Weber
1998-06-21  0:00       ` Robert Dewar
1998-06-17  0:00   ` Mark D. McKinney
1998-06-21  0:00   ` Robert Dewar
replies disabled

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