comp.lang.ada
 help / color / mirror / Atom feed
From: "Alejandro R. Mosteo" <alejandro@mosteo.com>
Subject: Error: allocation from empty storage pool
Date: Thu, 12 Jul 2018 11:50:40 +0200
Date: 2018-07-12T11:50:40+02:00	[thread overview]
Message-ID: <pi789g$8c1$1@dont-email.me> (raw)

In a library I'm trying to have all allocations done from user-specified 
storage pools. There is no restriction on using the heap, as long as it 
comes from a user pool (that can default to the regular heap, of course).

The idea was then to use "pragma Default_Storage_Pool (null)" at the 
library root to ensure no use of default allocators, and wherever needed 
provide facilities to get a pool from the user.

However, this test fails:

---8<---

pragma Restrictions (No_Secondary_Stack); -- Just to be sure in this ex.
pragma Default_Storage_Pool (null);

procedure Anon is

    type Holder is record
       I : aliased Integer;
    end record;

    type Ref (Elem : access constant Integer) is limited null record;

    function To_Ref (Hold : aliased Holder) return Ref is
      (Elem => Hold.I'Access); -- Error in subject here

begin
    null;
end Anon;

---8<---

There's actually no allocation being made, and I could have a Holder 
variable in the stack, and take a reference, and still no pool would be 
used at all.

So it seems this pragma is too naïve. To make it into questions:

Is this the pragma expected behavior or a particularity of gnat? Is the 
approach reasonable? This is my first attempt at working in a 
"restricted" Ada environment so I don't really have a clear idea of the 
preferred way to do what I want. Also, I'd like if possible to avoid 
making everything generic on the user pool.

Thanks,
Álex.


             reply	other threads:[~2018-07-12  9:50 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-07-12  9:50 Alejandro R. Mosteo [this message]
2018-07-12 11:41 ` Error: allocation from empty storage pool Simon Wright
2018-07-12 12:14   ` Alejandro R. Mosteo
2018-07-12 21:08     ` Randy Brukardt
2018-07-13  8:02       ` Alejandro R. Mosteo
replies disabled

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