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.9 required=5.0 tests=BAYES_00 autolearn=unavailable autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail From: "Alejandro R. Mosteo" Newsgroups: comp.lang.ada Subject: Error: allocation from empty storage pool Date: Thu, 12 Jul 2018 11:50:40 +0200 Organization: A noiseless patient Spider Message-ID: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Injection-Date: Thu, 12 Jul 2018 09:50:41 -0000 (UTC) Injection-Info: reader02.eternal-september.org; posting-host="05404f8022147e7877a5fedcabd3bbff"; logging-data="8577"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/OKQR566UF10sY437z1YrR" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.8.0 Cancel-Lock: sha1:/v78PGOtLjn/A9fj7k2Wq70yALg= Content-Language: en-US X-Mozilla-News-Host: news://news.eternal-september.org:119 Xref: reader02.eternal-september.org comp.lang.ada:53775 Date: 2018-07-12T11:50:40+02:00 List-Id: 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.