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,FREEMAIL_FROM autolearn=unavailable autolearn_force=no version=3.4.4 X-Received: by 10.224.169.1 with SMTP id w1mr6248383qay.4.1376422568655; Tue, 13 Aug 2013 12:36:08 -0700 (PDT) X-Received: by 10.49.30.8 with SMTP id o8mr89973qeh.36.1376422568630; Tue, 13 Aug 2013 12:36:08 -0700 (PDT) Path: border1.nntp.dca3.giganews.com!border3.nntp.dca.giganews.com!border1.nntp.dca.giganews.com!nntp.giganews.com!f7no2250309qan.0!news-out.google.com!he10ni1415qab.0!nntp.google.com!fx3no2361006qab.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Tue, 13 Aug 2013 12:36:08 -0700 (PDT) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=91.7.39.245; posting-account=rmHyLAoAAADSQmMWJF0a_815Fdd96RDf NNTP-Posting-Host: 91.7.39.245 References: <90b5c304-417e-4303-931c-e86d34e17541@googlegroups.com> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <988e9ddb-e58a-4d52-9b43-71a080890dd4@googlegroups.com> Subject: Re: Questions on Storage Pools From: AdaMagica Injection-Date: Tue, 13 Aug 2013 19:36:08 +0000 Content-Type: text/plain; charset=ISO-8859-1 X-Original-Bytes: 4011 Xref: number.nntp.dca.giganews.com comp.lang.ada:183005 Date: 2013-08-13T12:36:08-07:00 List-Id: On Monday, August 12, 2013 7:14:23 PM UTC+2, Adam Beneschan wrote: > I think you're confusing "finalization" with "storage reclamation". They're not the same thing. I guess you're right. The dust falling out of the worn RM is clearing now. Thanx Adam. > An access type can have a Storage_Size clause, or it can have a Storage_Pool clause. It cannot have both (13.11(3)). Yes, I know. > If it has a Storage_Size clause, the intent is that some block of memory (whose size is Storage_Size plus possibly a little extra) is set aside, and all "new" operations that return the access type use memory in that block for the new object. I understand and know this. But: Is there a GNAT GPL 2013 bug in this program: declare type Dyn is new Ada.Finalization.Controlled with record I: Integer; end record; overriding procedure Finalize (X: in out Dyn) is begin Put_Line ("Finalizing" & Integer'Image (X.I)); end Finalize; type Dyn_Access is access Dyn with Storage_Size => 100; procedure Free is new Ada.Unchecked_Deallocation (Dyn, Dyn_Access); -- Dyn_Access is frozen here, so the collection is implicitly defined here. Ptr: array (1 .. 5) of Dyn_Access; begin Ptr (1) := new Dyn'(Ada.Finalization.Controlled with I => 1); Ptr (2) := new Dyn'(Ada.Finalization.Controlled with I => 2); Ptr (3) := new Dyn'(Ada.Finalization.Controlled with I => 3); Free (Ptr (2)); -- Finalize is called here Ptr (2) := new Dyn'(Ada.Finalization.Controlled with I => 4); -- RM 7.6.1(11.1/3) -- Each nonderived access type T has an associated collection, which is the set of objects -- created by allocators of T... Unchecked_Deallocation removes an object from its collection. -- Finalization of a collection consists of finalization of each object in the collection, -- in an arbitrary order. The collection of an access type is an object implicitly declared -- at the following place: -- RM 7.6.1(11.2/3) -- For a named access type, the first freezing point (see 13.14) of the type. -- RM 13.11(18) -- If Storage_Size is specified for an access type, then ... the storage for the pool is -- reclaimed when the master containing the declaration of the access type is left. Put_Line ("Must finalize collection now and reclaim pool storage."); end; -- no Finalize called here! There is no finalization of the still existing allocated objects. The collection is dying, so it should be finalized and with it all still existing allocated objects. It's irrelevant if there is the aspect Storage_Size or not. If there is Storage_Size, the storage will be freed. If there is none, the storage remains allocated (with finalized objects inside). Correct?