comp.lang.ada
 help / color / mirror / Atom feed
From: M E Leypold <development-2006-8ecbb5cc8aREMOVETHIS@ANDTHATm-e-leypold.de>
Subject: Re: A smaller self contained test case. Was: Compiler Bug or what I'm doing wrong?
Date: 25 Jun 2006 12:51:15 +0200
Date: 2006-06-25T12:51:15+02:00	[thread overview]
Message-ID: <0ifyhtv78c.fsf@hod.lan.m-e-leypold.de> (raw)
In-Reply-To: 5v7eb8ink18v$.2y1201vcnkcc.dlg@40tude.net


"Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> writes:

> 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.

I didn't know that one could rename function results :-). Never had
seen that. But now that I see it, it makes a lot of sense. My
experiments indicate that a lot less finalizers/initializers run with
that pattern. That is good and I'll keep that in mind.

Also, thinking about it, that should be solution to initializing
limited values, wich I have been looking for and never foudn it (AFAIK
Barnes is silent on that). I assume the following would work (with
B_Type being a limited type)?

   declare B : B_Type renames Make_a_B(...);

> Anyway, the following will work as well:


Unfortunately all that doesn't remove my original Bug. The original
program (not the simplified example) has a more complex data structure
and a kind of filesystem/database. If I replace Read/Write by
Input/Output there, the bug persists. 

In the really simple example I submitted, tha bug goes away, but I
consider this accidental (due to the Heisenbug nature of
initialization- and malloc()-related bugs). When trying to replace the
Unbounded_String(s) in the example by Controlled types A_Class and
B_Class which print when their finalizes/initializers/asjustment are
run, I get mixed, partially non reproducible results:

  - I had a case where it seemed, that one initializer too many is
    run. When trying to change the tracing that effect vanished and
    couldn't be restored.

  - I had a case where during Read no initializers/finalizers whatever
    where run, but the discriminant was changed. The finalizer for the
    non-visible variant part (non-visible with the changed
    dioscriminant) was run at block exit but on the data content of
    the visible variant part.

All that indicates that the problem in question is not simply a
problem ion the order of operations as a surmised before. It looks a
bit like a caching problem: When at block exit the runtime examines
the discriminant it seems to have retained the old value somewhere and
act on that. I hoped, that switching of optimization (-O0) would make
that kind of bug go away, but didn't change anything.

I'm stuck for the moment. Simple workarounds obviously don't cover the
more complex cases (variant parts in varaint parts in variant
parts). Either I will have to write IO-procedure manually, or I'll
have to change to another compiler. Well.

Regards -- Markus









  reply	other threads:[~2006-06-25 10:51 UTC|newest]

Thread overview: 52+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-06-20 16:56 Compiler Bug or what I'm doing wrong? M E Leypold
2006-06-21  7:44 ` Ludovic Brenta
2006-06-21 12:29   ` M E Leypold
2006-06-21 12:46     ` Alex R. Mosteo
2006-06-21 13:23       ` M E Leypold
2006-06-22 19:10         ` Simon Wright
2006-06-23  8:24         ` Ludovic Brenta
2006-06-23 13:14         ` Alex R. Mosteo
2006-06-23 13:24           ` Alex R. Mosteo
2006-06-24 20:33             ` Simon Wright
2006-06-24 20:56               ` M E Leypold
2006-06-26  7:32                 ` Ludovic Brenta
2006-06-26 11:16                   ` M E Leypold
2006-06-26 12:13                     ` [Ada in Debian] GtkAda and GNAT versions Ludovic Brenta
2006-06-26 12:25                       ` M E Leypold
2006-06-27 20:55                   ` Compiler Bug or what I'm doing wrong? Simon Wright
2006-06-27 22:26                     ` Ludovic Brenta
2006-06-22  2:07       ` James Dennett
2006-06-22  6:37         ` Duncan Sands
2006-06-22 16:53           ` M E Leypold
2006-06-22 19:01             ` Pascal Obry
2006-06-23  8:37               ` M E Leypold
2006-06-22 19:05             ` Dmitry A. Kazakov
2006-06-23  4:47               ` Jeffrey R. Carter
2006-06-23 12:26               ` Stephen Leake
2006-06-23 13:11                 ` Dmitry A. Kazakov
2006-06-23 13:15                 ` Alex R. Mosteo
2006-06-23  9:55 ` A smaller self contained test case. Was: " M E Leypold
2006-06-23 10:03   ` M E Leypold
2006-06-23 11:04   ` And a Workaround: Was: A smaller test case / Compiler Bug M E Leypold
2006-06-23 11:12     ` Possible memory leaks when reading/writing variant records M E Leypold
2006-06-24 11:46   ` A smaller self contained test case. Was: Compiler Bug or what I'm doing wrong? Dmitry A. Kazakov
2006-06-24 12:27     ` M E Leypold
2006-06-24 12:52       ` Dmitry A. Kazakov
2006-06-24 13:53         ` M E Leypold
2006-06-24 19:58           ` Dmitry A. Kazakov
2006-06-24 20:22             ` M E Leypold
2006-06-25  7:59               ` Dmitry A. Kazakov
2006-06-25 10:51                 ` M E Leypold [this message]
2006-06-26  6:22                   ` Martin Dowie
2006-06-24 21:21             ` M E Leypold
2006-06-25 21:36   ` M E Leypold
2006-06-26 21:53   ` Possibly fixed in gcc 4.1.1, but bug box -- Was: Re: A smaller self contained test case M E Leypold
2006-06-27 18:24     ` Alex R. Mosteo
2006-06-27 22:58       ` M E Leypold
2006-06-28 10:32         ` Alex R. Mosteo
2006-07-03  1:38         ` Steve Whalen
2006-07-03 10:36           ` M E Leypold
2006-06-28  8:41       ` Ludovic Brenta
2006-06-28  8:51         ` Georg Bauhaus
2006-06-28 10:43         ` Alex R. Mosteo
2006-06-23 10:00 ` Compiler Bug or what I'm doing wrong? M E Leypold
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox