comp.lang.ada
 help / color / mirror / Atom feed
From: adam@irvine.com (Adam Beneschan)
Subject: Language lawyer question: Equality on 'Access attributes
Date: 7 Jan 2004 18:05:45 -0800
Date: 2004-01-07T18:05:45-08:00	[thread overview]
Message-ID: <b4682ab7.0401071805.5bc07078@posting.google.com> (raw)

Given this code:

package Pak1 is
    type Ptr1 is access all Integer;
    X : aliased Integer;
    Y : aliased Integer;
    B : Boolean := X'Access = Y'Access;
end Pak1;

GNAT gives me this error: "two access attributes cannot be compared
directly / they must be converted to an explicit type for comparison".

But I can't figure out why this should be an error.  Based on my
understanding of the language: The compiler needs to figure out
whether the interpretation of "X'Access = Y'Access" in which "="
denotes the equality operator implicitly defined for Ptr1 is an
acceptable interpretation (8.6(10-14)).  For a call to this "="
function, 6.4.1(3) says that the expected type for each argument is
Ptr1.  According to 3.10.2, X'Access and Y'Access do not have a
particular type out of context, but rather the types of these
constructs are determined by the expected type; when determining
whether these can be used as parameters to "=", the expected type is
Ptr1, and clearly it's legal to use X'Access or Y'Access in a
construct where the expected type is Ptr1.  So as far as I can tell,
this *is* an acceptable interpretation; and since there's only one "="
visible whose parameter types are access-to-integer, the requirement
of 8.6(30) is met that there be exactly one acceptable interpretation
of the function call, and thus this should be legal.  (If there were a
second access type, "type Ptr2 is access all integer", then B's
initialization expression would be ambiguous, since there would then
be two visible "=" operators for which the interpretation would be
acceptable.)  Note that the modified version of 3.10.2(2) in
AI95-00235 doesn't affect this analysis.

Is this analysis correct?  If not, where did I go wrong?  If I'm wrong
and GNAT is right, then could someone explain to me just how 8.6 and
3.10.2 are to be applied together when an 'Access attribute is used? 
The wording of the GNAT error message makes it appear to me that
GNAT's authors interpreted the RM as prohibiting this construct---but
I can't figure out where in the RM this would be prohibited.

                                     -- thanks, Adam



             reply	other threads:[~2004-01-08  2:05 UTC|newest]

Thread overview: 40+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-01-08  2:05 Adam Beneschan [this message]
2004-01-08  7:47 ` Language lawyer question: Equality on 'Access attributes Robert I. Eachus
2004-01-08 11:07   ` Dmitry A. Kazakov
2004-01-08 17:18   ` Adam Beneschan
2004-01-08 18:04     ` Robert A Duff
2004-01-08 18:31       ` Ze Administrator
2004-01-08 21:04         ` Robert A Duff
2004-01-09  4:02           ` Ze Administrator
2004-01-09 23:02             ` Robert A Duff
2004-01-10  2:56               ` Ze Administrator
2004-01-09  4:06           ` Ze Administrator
2004-01-09 23:05             ` Robert A Duff
2004-01-10  3:03               ` Ze Administrator
2004-01-10 13:47                 ` Marin David Condic
2004-01-10  7:19               ` Robert I. Eachus
2004-01-10 19:09                 ` Robert A Duff
2004-01-11 14:27                   ` Robert I. Eachus
2004-01-11 21:42                     ` Ze Administrator
2004-01-12  5:16                       ` Robert I. Eachus
2004-01-09  1:28         ` Adam Beneschan
2004-01-09  4:10           ` Ze Administrator
2004-01-09 11:27             ` Dmitry A. Kazakov
2004-01-09 23:09               ` Robert A Duff
2004-01-10 11:56                 ` Dmitry A. Kazakov
2004-01-10 17:08                   ` Robert I. Eachus
2004-01-10 18:40                   ` Robert A Duff
2004-01-09 23:08             ` Robert A Duff
2004-01-10  7:39               ` Robert I. Eachus
2004-01-08 20:36       ` tmoran
2004-01-08 21:06         ` Robert A Duff
2004-01-09  0:27       ` Randy Brukardt
2004-01-09  1:23       ` Adam Beneschan
2004-01-09  1:38         ` Robert A Duff
2004-01-09  6:16       ` Robert I. Eachus
2004-01-09 23:27         ` Randy Brukardt
2004-01-10 16:37           ` Robert I. Eachus
     [not found] ` <hmfvc1-f73.ln1@beastie.ix.netcom.com>
     [not found]   ` <l7v1d1-n33.ln1@beastie.ix.netcom.com>
2004-01-09 23:19     ` Robert A Duff
2004-01-09 23:21     ` Randy Brukardt
  -- strict thread matches above, loose matches on Subject: below --
2004-01-09  5:48 christoph.grein
2004-01-09  6:03 christoph.grein
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox