comp.lang.ada
 help / color / mirror / Atom feed
From: Laurent Guerby <guerby@acm.org>
Subject: Re: Program_Error because of Finalization.
Date: 2000/09/17
Date: 2000-09-17T11:34:19+00:00	[thread overview]
Message-ID: <86g0mz1cao.fsf@acm.org> (raw)
In-Reply-To: 39C3B125.209C0440@acm.org

Marin David Condic <mcondic.nospam@acm.org> writes:
> O.K., This one is a bit long. I'm having trouble using the Stream_IO
> facilities to input and output a class-wide type that is referenced with
> an access object. Basically, it works just fine so long as a) the object
> is just a static declaration with no pointer or b) I do not derive the
> class from Ada.Finalization. The smallest example I could come up with
> is here: [...]

Ada.Finalization.Controlled is likely to have some pointers in it, and
so using the predefined read/input attribute to build such an object from a
binary image is likely to cause havoc. The solution is to redefine
the stream attributes for your object to bypass the predefined ones.

I remember myself mentionning this issue (stream attribute on Controlled)
to the standard list while I was working on the distributed annex, but
I don't remember if some AI was issued or not.

Also, you might want to change

procedure Load (File: in out ASIO.File_Type ; Obj : in out Some_Type'Class) ;

to a function returning a class-wide type, since with the procedure
version, the tag will be determined by the caller actual and you
won't be able to change it inside Load.

declare
   X : Some_Type'Class := Load (F);
begin
  --...
end;

-- 
Laurent Guerby <guerby@acm.org>




       reply	other threads:[~2000-09-17  0:00 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <39C3B125.209C0440@acm.org>
2000-09-17  0:00 ` Laurent Guerby [this message]
2000-09-17  0:00   ` Program_Error because of Finalization Marin David Condic
2000-09-19  0:00     ` Tucker Taft
2000-09-19  0:00       ` Laurent Guerby
replies disabled

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