comp.lang.ada
 help / color / mirror / Atom feed
From: david.c.hoos.sr@ada95.com
Subject: Re: Storage_Error with parameterized records
Date: 1998/07/05
Date: 1998-07-05T00:00:00+00:00	[thread overview]
Message-ID: <6nntf2$u2m$1@nnrp1.dejanews.com> (raw)
In-Reply-To: 359D3A0C.13AF4C53@cl.cam.ac.uk


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
>
> I had hoped this code was sufficiently close to John Barnes
> Square example in chapter 16 of Programming in Ada 95 and I also
> didn't find a restriction in the RM that explained this warning.
>
> And idea?
>
> Markus
>
> --
> Markus G. Kuhn, Security Group, Computer Lab, Cambridge University, UK
> email: mkuhn at acm.org,  home page: <http://www.cl.cam.ac.uk/~mgk25/>
>
You didn't supply sufficient information to give a definitive answer.  E.g.,
you did not supply:

  1.  The compiler and platform you are using  2.  The value of the
discriminant with which the record object was declared.

If you consider that the range of type Natural on a 32-bit platform, and a 32-
bit size for type Float could call for just under 2 ** 63 bytes of memory for
an object of type Correlation_Matrix, then the reason for the warning
"creation of object of this type may raise Storage_Error" should be obvious.

The warning "Storage_Error will be raised at run-time" comes as a consequence
of declaring an object which is too large for the implementation.

E.g., with gnat-3.10p1 on Windows NT 4.0 (SP 3), an object of type
Correlation_Matrix declared with a discriminant of 8190 does not raise
Storage_Error at run time.  (The actual limit on the discriminant may depend
on how much other code there is in your program).

This size object represents just under 256 Mb. of memory.  Depending on the
implementation, the limits may be more severe.  E.g., depending on whether the
object was declared statically (e.g., in a package body), on the stack, or
using dynamic memory, the maximum size of an object may differ.

Finally, even though you may restrict the declarations such that the compile-
time warnings are eliminated, bear in mind that there may be run-time
Storage_Errors, if too many instances of legal-sized objects are created.

Hope this helps.

David C. Hoos, Sr.

-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp   Create Your Own Free Member Forum




  parent reply	other threads:[~1998-07-05  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 [this message]
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
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