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=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,d402e2c741db0d0,start X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2004-01-07 18:05:45 PST Path: archiver1.google.com!postnews1.google.com!not-for-mail From: adam@irvine.com (Adam Beneschan) Newsgroups: comp.lang.ada Subject: Language lawyer question: Equality on 'Access attributes Date: 7 Jan 2004 18:05:45 -0800 Organization: http://groups.google.com Message-ID: NNTP-Posting-Host: 66.126.103.122 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Trace: posting.google.com 1073527545 16196 127.0.0.1 (8 Jan 2004 02:05:45 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Thu, 8 Jan 2004 02:05:45 +0000 (UTC) Xref: archiver1.google.com comp.lang.ada:4193 Date: 2004-01-07T18:05:45-08:00 List-Id: 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