Boost logo

Boost :

From: Larry Evans (jcampbell3_at_[hidden])
Date: 2002-01-20 08:42:19

Thomas Maeder wrote:

> Am 2002.01.19 14:23 schrieb(en) David Abrahams:
> >
> > ...which is the reason it might be better if they didn't implicitly
> > convert, unless Peter's precautions are taken.
> Are there equivalent precautions against
> shared_ptr<Base> b(new Derived);
> ?

The following test driver snippet:

  ; {
    ; cout<<"TEST2:shared_ptr<SuperType> a_up(DerivedType*)"<<endl
    ; typedef subjAB subjBTM
    ; typedef subjB subjUP
    ; subjUP* a_make = new subjBTM
    ; shared_ptr<subjUP> a_up(a_make)
    ; cout<<"a_up.use_count(b4 reset)="<<a_up.use_count()<<endl
    ; a_up.reset()
    ; cout<<"a_up.get(after reset)="<<(void*)a_up.get()<<endl
  ; cout<<"subj_base::get_c_count="<<subj_base::get_c_count()<<endl

where "struct subjAB :public A,public B{...}", when compiled and run with
"gcc version 3.1 20011207 (experimental)", fails to delete a_make.

I am using Peter's
I've tried using gdb to trace and see what's happening, but it's skipping some
lines of code (I guess because of optimizing). Anyway, here's the output:

TEST1:shared_ptr<SuperType> a_up(shared_ptr<DerivedType>&)
a_btm.use_count(b4 reset)=2
subjB::operator b4 delete:0x80520e8
subjB::operator af delete:0x80520e8
a_btm.use_count(af reset)=1
TEST2:shared_ptr<SuperType> a_up(DerivedType*)
a_up.use_count(b4 exit scope)=1

The last line should have =0 and there should be some ~subj lines
after TEST2:.

I'll continue trying to get gdb to show something, but is anyone else
looking at this or have some ideas why it's happening. The code
is an easy modification of that I mentioned in my previous post.

Boost list run by bdawes at, gregod at, cpdaniel at, john at