|
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 http://groups.yahoo.com/group/boost/files/smart_ptr_3.zip.
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:
build/gcc/lib/gc_sel_ssp/tests/compiler_tests/gc_stl_collect_hide/main.multi_inherit_smart.exe
TEST1:shared_ptr<SuperType> a_up(shared_ptr<DerivedType>&)
+subj_base:c_count=1:m_id=1
+subjA:this=0x80520e8
+subjB:this=0x80520f0
+subjAB:this=0x80520e8
a_btm.use_count(b4 reset)=2
~subjAB:this=0x80520e8
~subjB:this=0x80520f0
~subjA:this=0x80520e8
~subj_base:c_count=0:m_id=1
subjB::operator b4 delete:0x80520e8
subjB::operator af delete:0x80520e8
a_btm.use_count(af reset)=1
subj_base::get_c_count=0
TEST2:shared_ptr<SuperType> a_up(DerivedType*)
+subj_base:c_count=1:m_id=2
+subjA:this=0x80520e8
+subjB:this=0x80520f0
+subjAB:this=0x80520e8
a_up.use_count(b4 exit scope)=1
subj_base::get_c_count=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 acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk