comp.lang.ada
 help / color / mirror / Atom feed
From: Georg Bauhaus <rm-host.bauhaus@maps.futureapps.de>
Subject: Re: GNAT: Why does a large 'new' allocation blow the stack when an initialiser is present ?
Date: Fri, 01 Nov 2013 16:04:44 +0100
Date: 2013-11-01T16:04:44+01:00	[thread overview]
Message-ID: <5273c30c$0$9505$9b4e6d93@newsspool1.arcor-online.net> (raw)
In-Reply-To: <lyk3gsse68.fsf@pushface.org>

On 01/11/13 09:45, Simon Wright wrote:
> Rod Kay <rodakay@internode.on.net> writes:
>
>>
>> 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.

Looking at the output of -gnatDG, I see that, for the second array,
a fresh one is simply declared, then initialized in a loop, and only
then an allocator creates the final array from the object just
initialized. I don't know whether this output reflects what the code
actually does, but it seems to agree with the above observations.



  parent reply	other threads:[~2013-11-01 15:04 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
2013-11-01 11:23   ` Rod Kay
2013-11-01 15:04   ` Georg Bauhaus [this message]
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