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!watserv1!watmath!att!att!emory!wuarchive!mit-eddie!uw-beaver!uw-june!simon From: simon@cs.washington.edu (Kevin Simonson) Newsgroups: comp.lang.ada Subject: assigning variant records Keywords: variant record access assign Message-ID: <13567@june.cs.washington.edu> Date: 29 Oct 90 23:48:59 GMT Organization: U of Washington, Computer Science, Seattle List-Id: 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;". 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 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ with TEXT_IO; use TEXT_IO; procedure VACH_PR is subtype DIGS is integer range 0..9; type XX (A : DIGS := 0) is record S : string (1..A); end record; type YY is access XX; X : XX; Y : YY; Z : string(1..20); I : integer; begin Y := new XX; loop put ("String: "); get_line (Z, I); exit when I = 1 and then Z(1) = 'q'; X := (I, Z(1..I)); Y.all := X; put_line ("Entered string is [" & Y.S & ']'); end loop; end VACH_PR; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2 3 procedure VACH_PR is 4 5 subtype DIGS is integer range 0..9; 6 7 type XX (A : DIGS := 0) is record 8 S : string (1..A); 9 end record; 10 11 type YY is access XX; 12 13 X : XX; 14 15 Y : YY; 16 17 Z : string(1..20); 18 19 I : integer; 20 21 begin 22 23 Y := new XX; 24 25 loop 26 put ("String: "); 27 get_line (Z, I); 28 exit when I = 1 and then Z(1) = 'q'; 29 X := (I, Z(1..I)); 30*= Y.all := X; 31 put_line ("Entered string is [" & Y.S & ']'); 32 end loop; 33 34 end VACH_PR; -*-------------------------------------------------------------------vach_pr.a- Debugging: /george4/simon/ada/vach_pr VADS_library: /george4/simon/ada library search list: /george4/simon/ada /indra1/local/ada/verdixlib /indra1/local/ada/standard :b 30 vach_pr String: Entered string is [] String: a ^ | before ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ after | V 2 3 procedure VACH_PR is 4 5 subtype DIGS is integer range 0..9; 6 7 type XX (A : DIGS := 0) is record 8 S : string (1..A); 9 end record; 10 11 type YY is access XX; 12 13 X : XX; 14 15 Y : YY; 16 17 Z : string(1..20); 18 19 I : integer; 20 21 begin 22 23 Y := new XX; 24 25 loop 26 put ("String: "); 27 get_line (Z, I); 28 exit when I = 1 and then Z(1) = 'q'; 29 X := (I, Z(1..I)); 30*= Y.all := X; 31 put_line ("Entered string is [" & Y.S & ']'); 32 end loop; 33 34 end VACH_PR; -*-------------------------------------------------------------------vach_pr.a- /george4/simon/ada /indra1/local/ada/verdixlib /indra1/local/ada/standard :b 30 vach_pr String: Entered string is [] String: a stopped at "/george4/simon/ada/vach_pr.a":8 in xx'2..SIZE 8 S : string (1..A); stopped 9 instructions after "/geoge4/simon/ada/vach_pr.a":30 in vach_pr'2 30 Y.all := X; "Illegal instruction" [4] --> Software trap: range check stopped 15 instructions after "/george4/simon/ada/vach_pr.a":30 in vach_pr'2 30 Y.all := X; -- Murphy's Law of Aerodynamics: When the weight of the paperwork equals the weight of the airplane, the airplane flies.