From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-0.8 required=5.0 tests=BAYES_00,INVALID_DATE autolearn=no autolearn_force=no version=3.4.4 Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!usc!zaphod.mps.ohio-state.edu!rpi!bu.edu!inmet!stt From: stt@inmet.inmet.com Newsgroups: comp.lang.ada Subject: Re: assigning variant records Message-ID: <20600073@inmet> Date: 19 Nov 90 23:16:00 GMT References: <13567@june.cs.washington.edu> Nf-ID: #R:june.cs.washington.edu:13567:inmet:20600073:000:1566 Nf-From: inmet.inmet.com!stt Nov 19 18:16:00 1990 List-Id: 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