comp.lang.ada
 help / color / mirror / Atom feed
From: cis.ohio-state.edu!zaphod.mps.ohio-state.edu!rpi!bu.edu!inmet!stt@ucbvax.
Subject: Re: Help with VAX/VMS Ada
Date: 12 Aug 91 19:39:00 GMT	[thread overview]
Message-ID: <20600114@inmet> (raw)

> Re: Help with VAX/VMS Ada by UN025523@WVNVAXA.WVNET.EDU 

>     type Vector (Lower_Bound, Upper_Bound : Integer := 0) is
>        record
>           The_Vector  : Vector_Array (Lower_Bound .. Upper_Bound)
> 	     := (others => Zero);
>        end record;

By providing a default for all discriminants, you are allowing the
declaration of unconstrained instances of Vector.

E.g., the following would now be legal:
   X : Vector;

In this situation, most Ada compilers will allocate
space sufficient to hold the largest possible value.
In this case, the largest value is truly enormous,
because the range of the discriminants is Integer.
The message from the compiler indicates that a CONSTRAINT_ERROR
is likely when computing this size of this largest value.

To avoid this problem, define an appropriate subtype of Integer
which provides a reasonable upper bound on the range of indices
for your vector.  E.g.:

   subtype Vector_Index_Range is Integer range 0..100;
   type Vector(LB, UB : Vector_Index_Range := 0) is ...

Now, the largest value is when LB = 0 and UB = 100.
This value is of reasonable size.

S. Tucker Taft     stt@inmet.inmet.com
Intermetrics, Inc.
Cambridge, MA  02138 

             reply	other threads:[~1991-08-12 19:39 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1991-08-12 19:39 cis.ohio-state.edu!zaphod.mps.ohio-state.edu!rpi!bu.edu!inmet!stt [this message]
  -- strict thread matches above, loose matches on Subject: below --
1991-08-14  4:54 Help with VAX/VMS Ada Mike Feldman
1991-08-05 19:24 James Burnell, WVU Comp/Ele Engr
replies disabled

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