comp.lang.ada
 help / color / mirror / Atom feed
From: smize@news.imagin.net (Samuel Mize)
Subject: Re: Storage_Error with parameterized records
Date: 1998/07/10
Date: 1998-07-10T00:00:00+00:00	[thread overview]
Message-ID: <6o5b7r$36aq$1@prime.imagin.net> (raw)
In-Reply-To: 359D3A0C.13AF4C53@cl.cam.ac.uk

If you create an unconstrained instance of this type, your compiler
allocates enough space to hold the largest example: an array of
Natural*Natural elements.  This is large.

If you only create constrained instances, you should be OK.  If you
need to be able to change the constraint, you need to determine the
largest constraint you may need, and use a subtype constrained by
that maximum value (instead of Natural) for the constraint.  Depending
on how smart the compiler is, you may need to use that subtype for
the indices of CMatrix too.

Best,
Sam Mize

In article <359D3A0C.13AF4C53@cl.cam.ac.uk>,
Markus Kuhn  <Markus.Kuhn@cl.cam.ac.uk> wrote:
>May be I have something severely missunderstood, but I have no idea,
>why the declaration
>
>   subtype Correlation_Coefficient is Float;
>
>   type CMatrix is
>      array (Natural range <>, Natural range <>) of
>        Correlation_Coefficient;
>
>   type Correlation_Matrix(Last_Line : Natural := 0) is
>      record
>	 Mat : CMatrix(0 .. Last_Line, 0 .. Last_Line);
>      end record;
>
>causes the following warnings (and at runtime the promised
>Storage_Error):
>
>  warning: Storage_Error will be raised at run-time
>  warning: creation of object of this type may raise Storage_Error


-- 
Samuel Mize -- smize@imagin.net (home email) -- Team Ada
Fight Spam: see http://www.cauce.org/ \\\ Smert Spamonam




  parent reply	other threads:[~1998-07-10  0:00 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1998-07-03  0:00 Storage_Error with parameterized records Markus Kuhn
1998-07-04  0:00 ` Pascal MALAISE
1998-07-05  0:00 ` david.c.hoos.sr
1998-07-08  0:00   ` Robert A Duff
1998-07-08  0:00     ` Robert Dewar
     [not found] ` <dewar.899586342@merv>
     [not found]   ` <359F50D9.5126DEE1@cl.cam.ac.uk>
1998-07-07  0:00     ` Robert Dewar
1998-07-10  0:00 ` Samuel Mize [this message]
1998-07-13  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