From: stt@inmet.inmet.com
Subject: Re: assigning variant records
Date: 19 Nov 90 23:16:00 GMT [thread overview]
Message-ID: <20600073@inmet> (raw)
In-Reply-To: 13567@june.cs.washington.edu
Re: assigning variant records
> /* Written 6:48pm Oct 29,1990 by simon@cs.washington.edu */
>
> He-e-e-elp!
>
> I have gotten the following Ada code to compile on a Verdix compiler
> used by the P-3 project at Boeing A&E, and have run it several times. Now
> that I'm a grad student at the University of Washington it still compiles,
> but when I try to run it, inputting into "get_line" a string of length 1 or
> more (as shown in the following debugging sessions), I get an
> '"Illegal instruction" [4]' message, followed by
> '--> Software trap: range check', as soon as I try to assign "Y.all := X;".
Your problem is that objects created by an allocator are always
constrained, even if the declaration of the record
type has defaults for all discriminants.
RM 4.8:5 states: "If the type of the created object is an array type
or a type with discriminants then the created
object is always constrained. If the allocator includes a subtype
indication, the created object is constrained either by
the subtype or by the default discriminant values."
In your case, you had "Y := new XX;". This creates
an object which is constrained by the default discriminant value,
which is 0. It rejects your attempt to assign a value into
it with a different discriminant.
> Can anybody make any sense out of this? What am I doing wrong? I'd
> really appreciate any advice anyone can give me. Thanks,
>
> ---Kevin Simonson
I hope this helped.
S. Tucker Taft
Intermetrics, Inc.
Cambridge, MA 02138
next prev parent reply other threads:[~1990-11-19 23:16 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
1990-10-29 23:48 assigning variant records Kevin Simonson
1990-11-19 23:16 ` stt [this message]
-- strict thread matches above, loose matches on Subject: below --
1990-10-30 15:20 "Norman H. Cohen"
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox