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.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,528b3cda1ec091b6,start X-Google-Attributes: gid103376,public From: matthew_heaney@acm.org (Matthew Heaney) Subject: Generic Actual Tagged Objects Not Implicitly Aliased? Date: 1998/04/29 Message-ID: #1/1 X-Deja-AN: 348673065 Content-Transfer-Encoding: 8bit Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Organization: Network Intensive Newsgroups: comp.lang.ada Date: 1998-04-29T00:00:00+00:00 List-Id: Suppose we have the following tagged type: type T is tagged limited ...; When I pass an object of type T to a subprogram, it is implicitly aliased, ie procedure Op (O : in out T) is begin ... O'Access ... Taking the 'Access of subprogram arg O is perfectly legal. Now, suppose I have a generic declaration generic O : in out T; package GP is ...; package body GP is .... O'Access ... package Objects is O : T; end; with Objects; package P is new GP (O); My compiler (GNAT 3.10p) is telling me that that instantiation of P is illegal, becuase O is not declared as aliased. I can make the compiler happy by declaring O as aliased: package Objects is O : aliased T; end; package P is new GP (O); And now all is well. This behavior begs certain questions: 1) Why can't you take the 'Access of generic formal object of a tagged type, without the actual object being declared as aliased? This would make the behavior consistant with that for subprogram parameters. 2) Isn't this a contract violation? Shouldn't the legality of the unit be determined at the time of compilation of the generic? How does the client know he's supposed to declare the generic actual object as aliased, unless he tries to compile the instantiation? (This is redolent of the Ada 83 behavior for unconstrained generic actual types.) 3) Why can't you declare an "access" formal object, ie generic O : access T; package GP is ...; At least this way it tells the client up front that the generic actual object needs to be declared as aliased. Thanks, Matt