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.2 required=5.0 tests=BAYES_00,INVALID_MSGID, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,5ccd8ee851fe2e00 X-Google-Attributes: gid103376,public From: ncohen@watson.ibm.com (Norman H. Cohen) Subject: Re: Record aggregate question (language lawyer needed!) Date: 1996/06/21 Message-ID: <4qf5el$1633@watnews1.watson.ibm.com>#1/1 X-Deja-AN: 161452941 distribution: world references: organization: IBM T.J. Watson Research Center keywords: record aggregate bug reply-to: ncohen@watson.ibm.com newsgroups: comp.lang.ada Date: 1996-06-21T00:00:00+00:00 List-Id: In article , mcriley@BIX.com (mcriley on BIX) writes: |> |> The following test program is accepted without question by one Ada |> compiler and executes without any qualms, while another warns of |> a constraint_error at runtime. Which is correct, or, is the exact |> implementation left up to the compiler implementor? |> |> procedure Rec_Test is |> |> type Task_Record_Type is |> record |> Originator : String (1 .. 20); |> Header_Dtg : String (1 .. 12); |> end record; |> |> Task_Record : Task_Record_Type := (others => (others => ' ')); |> |> begin |> null; |> end rec_test; |> |> The relevant part of the LRM is 4.3.1[1]: "A component association |> with the choice others [...] is only allowed if the represented |> components are all of the same type." Well the components are |> both of the same _type_, but obviously the subtype constraints vary. Since you quote the Ada-83 RM, Ada-83 AI-00244 applies. The summary of that AI is: In a record aggregate, a component association having multiple choices denoting components of the same type is considered equivalent to a sequence of single choice component associations representing the same components. Thus, what you have written is equivalent to Task_Record: Task_Record_Type := (Originator => (others => ' '), Header_Dtg => (others => ' ') ); It should work without problem. Perhaps the compiler that raises Constraint_Error (or threatens to) predates AI-00244, which received final approval in November 1986. The URL for the full text of AI83-00244 is: ftp://sw-eng.falls-church.va.us/public/AdaIC/standards/83com/ai-00244-bi.wj (By the way, the Ada-95 equivalent of the rule in RM83-4.3.1(1) is in the last sentence of RM95-4.3.1(16). The effect of AI83-00244 is captured in RM95-4.3.1(20).) -- Norman H. Cohen ncohen@watson.ibm.com