PATCH: for Serious v3 shared library bug

Phil Edwards pedwards@disaster.jaj.com
Mon Jan 8 16:48:00 GMT 2001


The proposed patch from Artem Khodush pushed this to the top of my
priority heap.  (Sorry, bad pun.)  I'll test that patch soon, and if it
works, this will be largely moot, but:


On Wed, Jan 03, 2001 at 12:49:09PM -0500, Phil Edwards wrote:
> > 
> > There is a difference between a streambuf and a filebuf.  Just by
> > tracing the source, it is clear to see that ~filebuf() closes the
> > descriptor.  A streambuf holds no descriptor, thus there is nothing to
> > close.
> 
> Right, but shouldn't a sequence like
> 
>     streambuf*  __old;
>     __ioinit._M_cout = new filebuf(1, "stdout", ios_base::out);
>     __old = cout.rdbuf(__ioinit._M_cout);
>     __old->~streambuf();
> 
> not call ~filebuf()?  This is one of the variations I tried in
> sync_with_stdio.
> 
> This may be a case where I'm being dense; the semantics of explicit dtor
> calls aren't something I'm an expert on.  And I don't yet have a working
> PDF reader to consult the standard.

Crumbs.  Looks like __old->~streambuf() will still call the filebuf dtor,
not just the streambuf dtor.  The example in [12/4]/12 includes:

    D  D_object;
    B* B_ptr = &D_object;

    B_ptr->~B();      //calls D s destructor

Although it appears from other parts of that example that a call of

    __old->streambuf::~streambuf();

might have done it.


Phil


-- 
pedwards at disaster dot jaj dot com  |  pme at sources dot redhat dot com
devphil at several other less interesting addresses in various dot domains
The gods do not protect fools.  Fools are protected by more capable fools.


More information about the Libstdc++ mailing list