Boost logo

Boost Users :

From: Petr Ferschmann (petr_at_[hidden])
Date: 2002-10-01 03:39:41


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hello,

I think I found BUG.
Let we have this program:
- -- cut here --
#include <boost/shared_ptr.hpp>
#include <boost/weak_ptr.hpp>
#include <boost/intrusive_ptr.hpp>
#include <cstdio>

using namespace std;

#define INTR

class MujObjekt
#ifdef INTR
: public boost::counted_base
#endif
{
public:
        MujObjekt()
        {
                printf( "MujObjekt::MujObjekt()\n" );
        }

        void setThis( boost::shared_ptr<MujObjekt> obj )
        {
                m_this = obj;
        }

        virtual ~MujObjekt()
        {
                printf( "MujObjekt::~MujObjekt()\n" );
        }

        boost::weak_ptr<MujObjekt> m_this;
};

int main()
{
        boost::shared_ptr<MujObjekt> obj( new MujObjekt() );
        obj->setThis( obj );

        return( 0 );
}
- --- cut here ---

But in case of usage of intrusive pointer it doesn't call destructor - because
there is weak pointer.

But when I undefine INTR and it uses non-intrusive it works as expected. This
is only modelling case to simulate bug.

- --
                                  Petr "Fers" Ferschmann

 -=[ petr_at_[hidden] ]==[ http://petr.ferschmann.cz/ ]=-
- -=[ Koukni na http://www.postcard.cz/ ]==[ +420 604/781 009 ]=-

GPG Fingerprint:
[83B0 6378 7A9D D993 035E 60BD FEEC F665 D2C8 1B9A]
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.7 (GNU/Linux)

iD8DBQE9mV9O/uz2ZdLIG5oRArF/AJ9LGfWTXfy69zNTsbiEKThTPQnWcwCeOWgj
0tX9AxdWJ8u/L1MkdZHjOPk=
=7A3i
-----END PGP SIGNATURE-----


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net