From: Simon Wright <simon@pushface.org>
Subject: Re: Error in gnat-4.6 (opensuse 11.4) ?
Date: Thu, 17 Mar 2011 14:34:29 +0000
Date: 2011-03-17T14:34:29+00:00 [thread overview]
Message-ID: <m2pqpphl3e.fsf@pushface.org> (raw)
In-Reply-To: 18becfb4-48a3-4e36-a078-48cfa444108b@x1g2000yqb.googlegroups.com
reinkor <reinkor@gmail.com> writes:
> raised STORAGE_ERROR : stack overflow (or erroneous memory access)
>
> If I change: "type Real is Digits 16;" -> "type Real is Digits
> 15;"
> then I do not get "stack overflow". Similarly, if I comment out for
> example the statement " fe,xe : fe_t;"
> type Real is Digits 16;
This (on Intel hardware) asks for what GNAT calls Long_Long_Float, which
requires 10 bytes. "digits 15" asks for Long_Float, which requires 8
bytes.
> type f_t is array(1..0400) of Real;
> type fe_t is array(1..1000) of Real;
>
> type Node_t is
> record
> f, fm : f_t;
> fe,xe : fe_t;
> x : Real;
> end record;
>
> Node : array (1..200) of Node_t;
Node is declared on the stack, and uses 200*(400+400+1000+1000+1) =
560_000 Reals, which for Long_Float uses under 5MB of stack, for
Long_Long_Float uses just over and is probably the cause of your
reported stack_overflow.
You might be able to improve matters by using the ulimit command; it
didn't work here (Mac OS X). The only real way is to use heap
allocation:
type Node_Array is array (Positive range <>) of Node_t;
type Node_Array_P is access Node_Array;
Node : Node_Array_P := new Node_Array (1..200);
next prev parent reply other threads:[~2011-03-17 14:34 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-03-17 13:33 Error in gnat-4.6 (opensuse 11.4) ? reinkor
2011-03-17 14:34 ` Simon Wright [this message]
2011-03-17 16:50 ` Jeffrey Carter
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox