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.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!mx02.eternal-september.org!feeder.eternal-september.org!aioe.org!.POSTED!not-for-mail From: "Dmitry A. Kazakov" Newsgroups: comp.lang.ada Subject: GNAT GPL 2015 (generics and pool-specific access types) Date: Tue, 16 Jun 2015 19:19:17 +0200 Organization: cbb software GmbH Message-ID: References: Reply-To: mailbox@dmitry-kazakov.de NNTP-Posting-Host: evoS9sCOdnHjo0GRLLMU1Q.user.speranza.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Complaints-To: abuse@aioe.org User-Agent: 40tude_Dialog/2.0.15.1 X-Notice: Filtered by postfilter v. 0.8.2 Xref: news.eternal-september.org comp.lang.ada:26349 Date: 2015-06-16T19:19:17+02:00 List-Id: On Tue, 16 Jun 2015 15:09:50 +0200, Dmitry A. Kazakov wrote: > On Mon, 15 Jun 2015 08:39:19 -0700 (PDT), Anh Vo wrote: > >> GNAT GPL 2015 is available. > > 1. There seems to be an issue with generics (always generics) in Ada 2012 > mode. The same code compiles in either 95 or 2005 mode. But in 2012 GNAT > gives "incompatible types" upon instantiation (in a declaration of a > pool-specific access type). I am trying to figure out what is going on. I tracked down the issue. The error appears upon a generic instantiation when a local access type is declared as pool-specific and the pool object is class-wide, e.g. function Foo (P : Pool) return ... is type Ptr is access T; -- Error, "incompatible types" for Ptr'Storage_Pool use P.Self.all; -- Rosen's trick Self is an access to Pool'Class to work around the in-mode of P. To get it compiled convert to a specific pool type: function Foo (P : Pool) return ... is type Ptr is access T; -- Now this is OK for Ptr'Storage_Pool use Pool (P.Self.all); ------------------------------------------------------------------------------------------------ Leaving aside the garbage error message, which compiler was wrong, Ada 95-2005 or Ada 2012? Then there is an interesting question about the behavior of "for" clause. Is it legal to use a class-wide instance for Storage_Pool object? Say there are pool types Pool_Parent and Pool_Child derived from it. If Pool_Child overrides Allocate. Then with P : Pool_Child; which Allocate to be called for an access type Ptr: 1. for Ptr'Storage_Pool use Pool_Parent (P); Should it "dispatch" to Pool_Child's Allocate? 2. for Ptr'Storage_Pool use Pool_Parent'Class (P); Is this legal? Should it "dispatch"? -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de