comp.lang.ada
 help / color / mirror / Atom feed
From: cis.ohio-state.edu!zaphod.mps.ohio-state.edu!saimiri.primate.wisc.edu!apl cen.apl.jhu.edu!ddsdx2.jhuapl.edu!dlc@ucbvax.Berkeley.EDU  (Dave Collard x7468)
Subject: Re: null arrays
Date: 18 Nov 92 13:22:53 GMT	[thread overview]
Message-ID: <1992Nov18.132253.17081@aplcen.apl.jhu.edu> (raw)

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

             reply	other threads:[~1992-11-18 13:22 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1992-11-18 13:22 cis.ohio-state.edu!zaphod.mps.ohio-state.edu!saimiri.primate.wisc.edu!apl [this message]
  -- strict thread matches above, loose matches on Subject: below --
1992-11-18 14:48 null arrays Douglas N. Surber
1992-11-20 20:38 Tucker Taft
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox