comp.lang.ada
 help / color / mirror / Atom feed
From: simon@cs.washington.edu (Kevin Simonson)
Subject: assigning variant records
Date: 29 Oct 90 23:48:59 GMT	[thread overview]
Message-ID: <13567@june.cs.washington.edu> (raw)


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.

             reply	other threads:[~1990-10-29 23:48 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1990-10-29 23:48 Kevin Simonson [this message]
1990-11-19 23:16 ` assigning variant records stt
  -- 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