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=-0.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,ec3de1b455c3909f X-Google-Attributes: gid103376,domainid0,public,usenet X-Google-Language: ENGLISH,UTF8 Path: g2news1.google.com!news1.google.com!eweka.nl!lightspeed.eweka.nl!83.128.0.12.MISMATCH!news-out2.kabelfoon.nl!newsfeed.kabelfoon.nl!xindi.nntp.kabelfoon.nl!newsfeed.freenet.de!news-lei1.dfn.de!news.uni-weimar.de!not-for-mail From: stefan-lucks@see-the.signature Newsgroups: comp.lang.ada Subject: Re: unexpected behaviour of finalize Date: Fri, 4 Apr 2008 19:51:28 +0200 Organization: Bauhaus-Universitaet Weimar Message-ID: References: <308722a0-7372-4a2b-9dbd-8d8704a3fcae@s33g2000pri.googlegroups.com> Reply-To: stefan-lucks@see-the.signature NNTP-Posting-Host: medsec1.medien.uni-weimar.de Mime-Version: 1.0 Content-Type: MULTIPART/MIXED; BOUNDARY="8323584-1395198509-1207331466=:3841" X-Trace: tigger.scc.uni-weimar.de 1207331934 23687 141.54.178.228 (4 Apr 2008 17:58:54 GMT) X-Complaints-To: news@tigger.scc.uni-weimar.de NNTP-Posting-Date: Fri, 4 Apr 2008 17:58:54 +0000 (UTC) X-X-Sender: lucks@medsec1.medien.uni-weimar.de In-Reply-To: <308722a0-7372-4a2b-9dbd-8d8704a3fcae@s33g2000pri.googlegroups.com> Content-ID: Xref: g2news1.google.com comp.lang.ada:20814 Date: 2008-04-04T19:51:28+02:00 List-Id: This message is in MIME format. The first part should be readable text, while the remaining parts are likely unreadable without MIME-aware tools. --8323584-1395198509-1207331466=:3841 Content-Type: TEXT/PLAIN; CHARSET=UTF-8 Content-Transfer-Encoding: 8BIT Content-ID: > This looks like a pretty clear compiler bug, especially since by the > time Finalize is called by the outermost Do_Something, it's using, for > the value of I, the parameter from a Do_Something call that is no > longer active. It shouldn't be hard to modify this slightly, using > (say) a string or record as a parameter to Do_Something, to create a > test where utter garbage is displayed; then it would be clearer that > this is a compiler bug. Good idea! Yes, the following change makes the program output a bit of garbage, as you guessed: procedure Strong_Fin_Test_Case is type Fin is new Ada.Finalization.Limited_Controlled with null record; procedure Do_Something (I: Natural) is A: String(1 .. 5); -- this is new type My_Fin is new Fin with null record; overriding procedure Finalize(Self: in out My_Fin) is begin Ada.Text_IO.Put_Line(" Do_Something Finalization " & A); end Finalize; Singleton: My_Fin; begin -- Do_Something Ada.Text_IO.Put_Line(" I = " & Natural'Image(I)); if I>0 then Do_Something(I-1); Do_Something(I-1); end if; A(1 .. 5) := ("ABCDE"); -- always the same end Do_Something; begin Ada.Text_IO.Put_Line("Start Do_Something (2)"); Do_Something(2); Ada.Text_IO.Put_Line("Stop Do_Something (2)"); end Strong_Fin_Test_Case; The putput: Start Do_Something (2) I = 2 I = 1 I = 0 Do_Something Finalization ABCDE I = 0 Do_Something Finalization ABCDE Do_Something Finalization ABCDE I = 1 I = 0 Do_Something Finalization ABCDE I = 0 Do_Something Finalization ABCDE Do_Something Finalization ABCDE Do_Something Finalization �l Stop Do_Something (2) The last line before "Stop Do_Something (2)" contains some strange characters instead of the constant "ABCDE" it should output. Furthermore, this output is not always the same. So long Stefan -- ------ Stefan Lucks -- Bauhaus-University Weimar -- Germany ------ Stefan dot Lucks at uni minus weimar dot de ------ I love the taste of Cryptanalysis in the morning! ------ --8323584-1395198509-1207331466=:3841--