From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.5-pre1 (2020-06-20) on ip-172-31-74-118.ec2.internal X-Spam-Level: X-Spam-Status: No, score=-1.9 required=3.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.5-pre1 Date: 18 Nov 92 14:48:45 GMT From: aio!dnsurber@tmc.edu (Douglas N. Surber) Subject: Re: null arrays Message-ID: List-Id: In jhb@dale.cts.com (John Bollenbacher) writes: >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); N2'first = 3 (LRM 4.5.3 4) >begin > I := N1'LENGTH; -- I = 0 > I := N2'LENGTH; -- I = 0 > O := (0, N1); -- does not raise constraint > O := (0, N2); -- raises constraint O.Data'first /= N2'first thus raises constraint error (LRM 4.3.1 3, 3.3 4) >end TEST; The trick here is that the constraint error is raised in forming the aggregate, not in the assignment. LRM 4.3.1 3 says "A check is made that the value of each subcomponent of the aggregate _belongs_ to the subtype of this component." The magic word is "belongs". LRM 3.3 4 says "a value is said to belong to a subtype of a given type if it belongs to the type and satisfies the constraint." The bounds of N2, i.e. 3 and 2, do not satisfy the constraint of the aggregate, i.e. in the range 1 .. 0. If this were an array assignment rather than an aggregate, it would work. Douglas Surber Lockheed Houston, TX