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,2f84446733b06aca X-Google-Attributes: gid103376,public From: "Norman H. Cohen" Subject: Re: Converting C++ class to Ada Date: 1996/12/20 Message-ID: <32BAD007.648F@watson.ibm.com>#1/1 X-Deja-AN: 205137904 references: <32ADF183.7195@lmtas.lmco.com> content-type: text/plain; charset=us-ascii organization: IBM Thomas J. Watson Research Center mime-version: 1.0 reply-to: ncohen@watson.ibm.com newsgroups: comp.lang.ada x-mailer: Mozilla 3.0 (Win95; I) Date: 1996-12-20T00:00:00+00:00 List-Id: (Removing comp.lang.c++ from list of newsgroups.) Jon S Anthony wrote: > In article mheaney@ni.net (Matthew > Heaney) writes: > ... > > I thought that access discriminants (and parameters) without an explicit > > type raise Program_Error when you pass "null" as the value? > > CE is raised if a null value is passed to an access _parameter_. I > have never seen anything indicating that CE (or PE) is raised if a > null value is given for the value of an access _discriminant_. A good > thing IMO on both counts. See in particular 11.5(11) > > Of course, given a recent little discussion on the GNAT chat list I > could simply have not found it yet... :-) But really, this point seems > pretty clear! No, Constraint_Error is raised for both a null access parameter and a null access discriminant. This point was just raised on the GNAT chat list (probably as a result of the discussion here in comp.lang.ada), and I replied, in part, as follows: A null access discriminant is a run-time error. 11.5 is just a list of the language-defined checks, together with an informal description of when the checks occur. The definitive rules about when a check is performed will be found in the "Dynamic Semantics" sections describing the execution, evaluation, or elaboration of the relevant constructs. The relevant construct in this case is a discriminant constraint: It is during the elaboration of a discriminant constraint that a null access discriminant would be caught. RM 3.7.1(12) says: "For the elaboration of a discriminant_constraint, the expressions in the discriminant_associations are evaluated in an arbitrary order and converted to the type of the associated discriminant (which might raise Constraint_Error--see 4.6)...." Hidden in 4.6(49) is the rule, "If the target type is an anonymous access type, a check is made that the value of the operand is not null...." (4.6(57) states that the exception raised when this check fails is Constraint_Error. The rule in RM 4.6(49) can be found using the index entry for "Access check".) -- Norman H. Cohen mailto:ncohen@watson.ibm.com http://www.research.ibm.com/people/n/ncohen