comp.lang.ada
 help / color / mirror / Atom feed
From: "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
Subject: GNAT GPL 2015 (generics and pool-specific access types)
Date: Tue, 16 Jun 2015 19:19:17 +0200
Date: 2015-06-16T19:19:17+02:00	[thread overview]
Message-ID: <ty8qyfaygj5u.1arirt2rf4zl2$.dlg@40tude.net> (raw)
In-Reply-To: vfd63o0ixsei$.prjhviv650ow$.dlg@40tude.net

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


      reply	other threads:[~2015-06-16 17:19 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-06-15 15:39 GNAT GPL 2015 Anh Vo
2015-06-16 11:56 ` gautier_niouzes
2015-06-16 12:14   ` David Botton
2015-06-16 12:23     ` gautier_niouzes
2015-06-16 13:26   ` G.B.
2015-06-16 13:39   ` Pascal Obry
2015-06-16 13:09 ` Dmitry A. Kazakov
2015-06-16 17:19   ` Dmitry A. Kazakov [this message]
replies disabled

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