comp.lang.ada
 help / color / mirror / Atom feed
* Default_Storage_Pool
@ 2018-02-21  2:00 sbelmont700
  2018-02-22  1:13 ` Default_Storage_Pool Randy Brukardt
  0 siblings, 1 reply; 4+ messages in thread
From: sbelmont700 @ 2018-02-21  2:00 UTC (permalink / raw)


Can anyone offer insight into what exactly should happen when Default_Storage_Pool is explicitly set within an extended return statement to a pool within the return object?  In particular, consider these shenanigans:

package O is

   pool_1 : My_Fancy_Pool
   pragma Default_Storage_Pool(pool_1);
   
   type T is limited
      record
         pool_2 : My_Fancy_Pool
         p1     : access Integer;
      end record;
   
   function F return T;
   
end O;

package body O is

   function F return T is
   begin
      return Result : T do
         declare
            pragma Default_Storage_Pool(Result.pool_2);  -- legal?
            p2 : access Integer;
         begin
            p2 := new integer'(42);
            Result.p1 := new integer'(43);
         end;
      end return;
   end F;
   
end O;
   
GNAT happily accepts this, but based on print lines, it allocates Result.p1 from pool_1 and p2 from some unspecified default pool (i.e. neither pool_1 or pool_2).  I wasn't sure what I was expecting; I assumed an error message, but failing that, both to go into result.pool_2, and was surprised to get neither.

Any clarifications are appreciated.

-sb


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2018-02-23  0:06 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-02-21  2:00 Default_Storage_Pool sbelmont700
2018-02-22  1:13 ` Default_Storage_Pool Randy Brukardt
2018-02-22 13:02   ` Default_Storage_Pool sbelmont700
2018-02-23  0:06     ` Default_Storage_Pool Randy Brukardt

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