From: Stephen Leake <Stephen.Leake@gsfc.nasa.gov>
Subject: Re: Help with gnat storage error
Date: 1997/06/24
Date: 1997-06-24T00:00:00+00:00 [thread overview]
Message-ID: <33AFFD4A.2E6E@gsfc.nasa.gov> (raw)
In-Reply-To: 5olggu$dcg$1@cdserv.rzg.mpg.de
Myriam Witt wrote:
> I'm using gnat's binary distribution
> gnat-3.09-sparc-sun-solaris2.4-bin.tar.gz
> on a SUN Ultra 2, Solaris 2.5.1 (anyone knows about a 2.5.1 binary?).
>
> During compile-/linktime I get some messages
> 'warning: creation of object of this type may raise Storage_Error'
> from code like
> ---
> type T_Polygon_XYZ (Max_Punkte: Natural := 1) is
> record
> Punkte : Natural := Max_Punkte; -- Anzahl der Polygonpunkte
> X : T_Vector_Float(1..Max_Punkte) := (others => 0.0);
> Y : T_Vector_Float(1..Max_Punkte) := (others => 0.0);
> Z : T_Vector_Float(1..Max_Punkte) := (others => 0.0);
> end record;
>
> where
>
> type T_Vector_Float is array(integer range <>) of Float;
This is because you might declare:
A : T_Polygon_XYZ (Natural'last);
which would use all of memory (or at least a lot of it!). You should use
a smaller range for Max_Punkte:
type Max_Punkte_Type is range 1 .. 1000;
type T_Polygon_XYZ (Max_Punkte: Max_Punkte_Type := 1) is
You have to pick a reasonable max value, but that is usually not hard.
If you really can not pick a max value, you should be using dynamic
allocation, and a linked list or other structure instead of an array.
--
- Stephe
next prev parent reply other threads:[~1997-06-24 0:00 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
1997-06-23 0:00 Help with gnat storage error Myriam Witt
1997-06-24 0:00 ` Kirk Beitz
1997-06-24 0:00 ` Stephen Leake [this message]
1997-06-25 0:00 ` Peter Hermann
1997-06-26 0:00 ` Myriam Witt
1997-06-28 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