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,ed6a891101ff4e06 X-Google-Attributes: gid103376,public From: tmoran@bix.com (Tom Moran) Subject: Re: Freeing Pointers to classwide types Date: 1998/09/26 Message-ID: <360c4a70.29707515@SantaClara01.news.InterNex.Net>#1/1 X-Deja-AN: 394947743 References: <1ftmFTC69GA.191@samson.airnet.net> <360b26a1.41575272@SantaClara01.news.InterNex.Net> <6ugeu2$79u$1@nnrp1.dejanews.com> Organization: InterNex Information Services 1-800-595-3333 Newsgroups: comp.lang.ada Date: 1998-09-26T00:00:00+00:00 List-Id: >> to free the memory pointed to by 'p' when it leaves procedure >> something. >Tom, there is absolutely no reason to "hope" this, since it is certainly >not required semantics with Ada.Finalization; package Test1 is type T is new Ada.Finalization.Controlled with null record; procedure Initialize(X : in out T); procedure Finalize(X : in out T); end Test1; with Ada.Text_IO; package body Test1 is procedure Initialize(X : in out T) is begin Ada.Text_IO.Put_Line("Initialize"); end Initialize; procedure Finalize(X : in out T) is begin Ada.Text_IO.Put_Line("Finalize"); end Finalize; end Test1; with Test1, Ada.Text_IO; procedure Test is procedure Something is type Ptr is access Test1.T; P : Ptr; begin Ada.Text_IO.Put_Line("start Something"); P := new Test1.T; Ada.Text_IO.Put_Line("end Something"); end Something; begin Ada.Text_IO.Put_Line("Start"); Something; Ada.Text_IO.Put_Line("End"); end Test; The three compilers I tried all produce: Start start Something Initialize end Something Finalize End Do you mean that it would be legal Ada to produce a different output, or that it should produce this but might not actually free the memory after the Finalize?