From: "Norman H. Cohen" <ncohen@watson.ibm.com>
Subject: Re: Converting C++ class to Ada
Date: 1996/12/20
Date: 1996-12-20T00:00:00+00:00 [thread overview]
Message-ID: <32BAD007.648F@watson.ibm.com> (raw)
In-Reply-To: JSA.96Dec11160847@alexandria
(Removing comp.lang.c++ from list of newsgroups.)
Jon S Anthony wrote:
> In article <mheaney-ya023280001812962110410001@news.ni.net> 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
next prev parent reply other threads:[~1996-12-20 0:00 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
1996-12-10 0:00 Converting C++ class to Ada Ken Garlington
1996-12-11 0:00 ` Larry Kilgallen
1996-12-11 0:00 ` Stephen Leake
1996-12-13 0:00 ` Stephen Leake
1996-12-11 0:00 ` Norman H. Cohen
1996-12-12 0:00 ` Jon S Anthony
1996-12-11 0:00 ` Jon S Anthony
1996-12-12 0:00 ` Ken Garlington
1996-12-18 0:00 ` Jon S Anthony
1996-12-18 0:00 ` Matthew Heaney
1996-12-19 0:00 ` Robert A Duff
1996-12-20 0:00 ` Stephen Leake
1996-12-20 0:00 ` Robert A Duff
1996-12-20 0:00 ` Jon S Anthony
1996-12-20 0:00 ` Mitch Gart
1996-12-20 0:00 ` Norman H. Cohen [this message]
1996-12-21 0:00 ` Jon S Anthony
1996-12-12 0:00 ` Dale Stanbrough
1996-12-12 0:00 ` Constructors for Ada (was: Converting C++ class to Ada) Matthew Heaney
1996-12-13 0:00 ` Norman H. Cohen
1996-12-13 0:00 ` Matthew Heaney
1996-12-17 0:00 ` Robert I. Eachus
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox