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.7 required=5.0 tests=BAYES_00,INVALID_DATE, MSGID_SHORT,REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!seismo!caip!clyde!arny@bonnie.ATT.COM From: arny@bonnie.ATT.COM Newsgroups: net.lang.ada Subject: Re: Allocator Subtypes Question Message-ID: <960@clyde.UUCP> Date: Fri, 5-Sep-86 13:30:44 EDT Article-I.D.: clyde.960 Posted: Fri Sep 5 13:30:44 1986 Date-Received: Fri, 5-Sep-86 22:01:18 EDT References: <12236430813.14.MENDAL@SU-SIERRA.ARPA> Sender: lp@clyde.UUCP Reply-To: arny@bonnie.UUCP (Arny Engelson) Organization: AT&T Bell Laboratories, Whippany NJ Keywords: Allocator, Subtypes List-Id: In article <12236430813.14.MENDAL@SU-SIERRA.ARPA> Mendal@SU-SIERRA.ARPA (Geoff Mendal) writes: > >We've read LMC-AI 00324/02, and paragraphs 4.8:3-6 of the Language >Reference Manual, but still have a question concerning the behavior >of the following program: > > procedure Main is > type A is access Integer range -10 .. 15; > X : A; > begin > X := new Natural'(-5); > ... > end; > >Does evaluation of the allocator raise Constraint_Error or not? >Why or why not. We would appreciate appropriate LRM references >to back up any "interpretations". Thanks in advance. > Yes, evaluation of the allocator raises Constraint_Error because the operand of the qualified expression used in the assignment (-5) is not within the type mark given (Natural). The qualified expression must be evaluated before its result can be assigned to the object designated by X. The appropriate reference in the LRM is section 4.7, paragraph 3 (Qualified Expressions). BTW, I checked it on the (validated) AT&T UNIX Ada compiler, and it checked out, but I don't know if the ACVC tests actually tested that or not. Anybody care to check? Thanks for a fun question, (hope the answer's correct!) Arny