home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.ada
- Path: sparky!uunet!zaphod.mps.ohio-state.edu!saimiri.primate.wisc.edu!aplcen.apl.jhu.edu!ddsdx2.jhuapl.edu!dlc
- From: dlc@ddsdx2.jhuapl.edu (Dave Collard x7468)
- Subject: Re: null arrays
- Message-ID: <1992Nov18.132253.17081@aplcen.apl.jhu.edu>
- Sender: news@aplcen.apl.jhu.edu (USENET News System)
- Organization: Johns Hopkins University
- References: <BxvtCA.LM1@dale.cts.com>
- Distribution: usa
- Date: Wed, 18 Nov 92 13:22:53 GMT
- Lines: 40
-
- In <BxvtCA.LM1@dale.cts.com> jhb@dale.cts.com (John Bollenbacher) writes:
-
- >Can somebody shed some light on the symptoms of the following program. In
-
- >-------------------cut here-----------------------------------------------
- >procedure TEST is
-
- > subtype T is NATURAL range 0 .. 10;
-
- > type ARR is array (T range <>) of BOOLEAN;
- >
- > type A(N : T := 0) is record
- > DATA : ARR(1..N);
- > end record;
- > I : INTEGER;
- > O : A := (3, (TRUE, FALSE, TRUE));
- >
- > N1 : constant ARR := O.DATA(1..0) & O.DATA(1..0);
- > N2 : constant ARR := O.DATA(1..0) & O.DATA(3..2);
-
- -- The result of concatenation of a null array and another array is
- -- an array with the range of the second array. Thus N1 has a range
- -- of 1..0 and N2 has a range of 3..2.
-
- >begin
- > I := N1'LENGTH; -- I = 0
- > I := N2'LENGTH; -- I = 0
- > O := (0, N1); -- does not raise constraint
- > O := (0, N2); -- raises constraint
-
- -- Given the above, this is the common sliding error. An aggregate assignment
- -- does not "slide" the indices to match the constraints of the array in your
- -- record. Since N1'First is 1, no problem. N2'First is 3 so it does
- -- not match 1..N.
-
- >end TEST;
-
- --Thor
- collard@capsrv.jhuapl.edu
- dlc@ddsdx2.jhuapl.edu
-