comp.lang.ada
 help / color / mirror / Atom feed
From: Georg Bauhaus <rm-host.bauhaus@maps.futureapps.de>
Subject: Re: Can't set executable stack size during compilation
Date: Thu, 05 Jan 2012 11:19:39 +0100
Date: 2012-01-05T11:19:32+01:00	[thread overview]
Message-ID: <4f057934$0$7623$9b4e6d93@newsspool1.arcor-online.net> (raw)
In-Reply-To: <CB2AD91F.DE37%yaldnif.w@blueyonder.co.uk>

On 1/5/12 5:35 AM, Bill Findlay wrote:

> As it happens, when I ran it I got:
>
>> /Users/wf/KDF9/emulation/Build: ./onstack
>>
>> raised CONSTRAINT_ERROR : onstack.adb:19 range check failed
>
> because my default GNAT switches ask it to (attempt to) check for uses of
> uninitialized variables.

A possible solution of GNAT's stack size issue, an Ada solutions of sorts,
appears to be available with tasking. Move the computation to a task
and add

    pragma Storage_Size (Minimum_Storage_Size);

in the task's declaration, thus

procedure Run_in_Task is

    type Num is range 1 .. 10000;
    type Index is range 1 .. 512;
    type Table is array (Index, Index) of Num;

    type Big is record
       X1, X2, X3, X4, X5: Table :=
         (others => (others => Num'First));
    end record;

    Minimum_Storage_Size : constant := 11_000_000;
    --  task's storage size; addressing stack size issues with GNAT
    --  about equal to 512 * 512 * 2 * 5 * 4

    task Onstack is
       pragma Storage_Size (Minimum_Storage_Size);
    end Onstack;

    task body Onstack is separate;

begin
    null;
end Run_in_Task;

separate (Run_in_Task)
task body OnStack is

    function Add (A, B : Big) return Big is
       Result : Big;

       function Add_Component (Left, Right: Table) return Table is
          Result : Table;
       begin
          for M in Left'Range loop
             for N in Right'Range loop
                Result (M, N) := Left(M, N) + Right(M, N);
             end loop;
          end loop;
          return Result;
       end Add_Component;

    begin
       Result.X1 := Add_Component (A.X1, B.X1);
       Result.X2 := Add_Component (A.X2, B.X2);
       Result.X3 := Add_Component (A.X3, B.X3);
       Result.X4 := Add_Component (A.X4, B.X4);
       Result.X5 := Add_Component (A.X5, B.X5);
       return Result;
    end Add;

    X, Y: Big;
    Data : Big;
begin
    Data := Add (X, Y);
    pragma Inspection_Point (Data);
end OnStack;



  reply	other threads:[~2012-01-05 10:22 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-01-04 15:49 Can't set executable stack size during compilation Erich
2012-01-04 16:27 ` Georg Bauhaus
2012-01-04 17:22   ` Bill Findlay
2012-01-04 21:36     ` Georg Bauhaus
2012-01-05  1:06       ` Randy Brukardt
2012-01-05  4:35         ` Bill Findlay
2012-01-05 10:19           ` Georg Bauhaus [this message]
2012-01-05 12:35             ` Erich
2012-01-05  3:03   ` Jerry
2012-01-05 13:20   ` Mark Lorenzen
2012-01-05  3:12 ` Jerry
replies disabled

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