comp.lang.ada
 help / color / mirror / Atom feed
From: Simon Wright <simon@pushface.org>
Subject: Re: GNAT: Why does a large 'new' allocation blow the stack when an initialiser is present ?
Date: Fri, 01 Nov 2013 08:45:51 +0000
Date: 2013-11-01T08:45:51+00:00	[thread overview]
Message-ID: <lyk3gsse68.fsf@pushface.org> (raw)
In-Reply-To: d843d1e1-a1ea-4818-b23d-aff833be2186@googlegroups.com

Rod Kay <rodakay@internode.on.net> writes:

> Hi all,
>
>    Is this a bug ?
>
> procedure bug_Test
> is
>    type Integer_array is array (Integer range <>) of Integer;
>    
>    the_Array_1 : access Integer_array 
>       := new Integer_array  (1 .. 10_000_000);         -- Fine.
>
>    the_Array_2 : access Integer_array
>       := new Integer_array' (1 .. 10_000_000 => <>);   -- Stack overflow.
>
> begin 
>    null;
> end;
>
>    It seems that, with the initialiser, GNAT is creating the array on
>    the stack before copying it to the final heap memory ?

Not sure precisely what the bug is, but something odd is going on.

This is on a Mac with GNAT GPL 2013.

The stack overflow occurs with an array length 2**21 but not 2**20.

The traceback shows it happening at the start of the procedure (line
"procedure bug_Test"). I put the declarations into their own declare
blocks with Put_Lines, and the first never got executed.

I'm not sure what "=> <>" is expected to do when there's no default
value; I added "with Default_Component_Value => 42" to Integer_Array,
and The_Array_1 (0) was 42 but The_Array_2 (1) was unchanged at 0!

  reply	other threads:[~2013-11-01  8:45 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-11-01  2:49 GNAT: Why does a large 'new' allocation blow the stack when an initialiser is present ? Rod Kay
2013-11-01  8:45 ` Simon Wright [this message]
2013-11-01 11:23   ` Rod Kay
2013-11-01 15:04   ` Georg Bauhaus
2013-11-01 10:19 ` sbelmont700
2013-11-01 11:28   ` Rod Kay
replies disabled

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