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.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,aa968038a51ee866 X-Google-Attributes: gid103376,public From: dewar@cs.nyu.edu (Robert Dewar) Subject: Re: Q: Ada.Unchecked_Deallocation Date: 1996/07/13 Message-ID: #1/1 X-Deja-AN: 168245609 references: <31E5D4D1.11DB36E1@jinx.sckans.edu> <4s5j6fINN3pj@faatcrl.faa.gov> organization: Courant Institute of Mathematical Sciences newsgroups: comp.lang.ada Date: 1996-07-13T00:00:00+00:00 List-Id: Ron Tompson said "What a mouthful. If the "new" object has a local scope, that is it is declared down here in this particular routine, then it is freed back to OS when this routine closes." First, let's be absolutely clear on what Ron means here, the scope of a new object is the scope of the corresponding access type (NOT the scope where the new object is allocated), so the routine being mentioned in the above is the routine containing the declaration of the corresponding access type. Second, this is *allowed* but not *required* behavior by compilers. Some wording in the Ada 83 RM strongly implied that an implementation might perform such a free (see description of pragma Controlled in the Ada 83 RM), but this was still not required (since it is from a formal point of view undetectable whether the obvject is or is not freed since it can no longer be referenced anyway). However this language has been removed from the Ada 95 RM. Our current view in GNAT is *not* to automatically free such storage by default (allowing for this automatic free adds quite a bit of overhead, which may not be needed in many cases). We plan to provide a storage pool option that will allow this automatic freeing if it is what you want. Gven that Ada 95 provides the control of storage pools, this seems the most reasonable approach. Consequently Ron's advoice that you don't need to free objects of a local allocator type if you don't need to free them before scope exit is generally incorrect for Ada 95 implementations (I believe the Intermetrics front end takes the same approach as GNAT).