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,fb264cdd67c2f20f X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news3.google.com!news.glorb.com!txtfeed1.tudelft.nl!tudelft.nl!txtfeed2.tudelft.nl!amsnews11.chello.com!newsfeed01.chello.at!newsfeed.arcor.de!news.arcor.de!not-for-mail From: "Dmitry A. Kazakov" Subject: Re: A smaller self contained test case. Was: Compiler Bug or what I'm doing wrong? Newsgroups: comp.lang.ada User-Agent: 40tude_Dialog/2.0.15.1 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Reply-To: mailbox@dmitry-kazakov.de Organization: cbb software GmbH References: <05lkrrojfd.fsf@hod.lan.m-e-leypold.de> <1cfjjgsg6wwv4.44snml2yzt42$.dlg@40tude.net> <7sr71erb6j.fsf@hod.lan.m-e-leypold.de> Date: Sun, 25 Jun 2006 09:59:35 +0200 Message-ID: <5v7eb8ink18v$.2y1201vcnkcc.dlg@40tude.net> NNTP-Posting-Date: 25 Jun 2006 09:59:33 MEST NNTP-Posting-Host: 53d62581.newsread4.arcor-online.net X-Trace: DXC=Ac9e5b`g9jGl=9hLK`A7fM:ejgIfPPldDjW\KbG]kaMH]kI_X=5KeaFOU1J>Z^i]HJ[6LHn;2LCVN[ On 24 Jun 2006 22:22:30 +0200, M E Leypold wrote: > I followed Barnes' advice here: "wether it is appropriate to use a > variant or tagged type, the key consideration is mutability". True [mutability of class instances] Handles to tagged types is another way to have mutable class-wide. >> procedure Get_Record is >> F : File_Type; >> S : Stream_Access; >> begin >> Open (F, Mode => In_File, Name => "tmp-bug3" ); >> S := Stream (F); >> for I in 1 .. 400 loop >> declare >> R : Customer_Description renames >> Customer_Description'Input (S); > > Oops. My, that is a dirty trick -- but how do I return R? Hm, yes I > can see how that would work. Perhaps :-). I'll see how I can fit that > into the database module. Hey, it is not a trick, but a nice pattern! I am using it quite often, and count it for a good style. Anyway, the following will work as well: procedure Get_Record is F : File_Type; S : Stream_Access; R : Customer_Description; begin Open (F, Mode => In_File, Name => "tmp-bug3" ); S := Stream (F); for I in 1 .. 400 loop R := Customer_Description'Input (S); Ada.Text_IO.Put_Line ("Read" & Integer'Image (I)); end loop; Close (F); end; As far as I can tell, the bug is not in finalization. It is rather in absence of. It seems that GNAT does *not* make it in Read when the discriminant gets changed *by* Read. Then, later, another finalization discovers rubbish. That never can happen when Input is used. So, it is safe to use Input in all combinations. Just a guess. -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de