Boost logo

Boost :

From: Tim Blechmann (tim_at_[hidden])
Date: 2008-03-24 10:36:40


>> the changes break the following code, though (maybe this can be added
>> to the shared_from_this_test.cpp test suite?):
>>
>> struct V: public boost::enable_shared_from_this<V> {};
>>
>> struct W: V
>> {};
>>
>> void test4(void)
>> {
>> W * w = new W();
>> boost::shared_ptr<W> p(w);
>> }
>
> You'll have to be more specific about the problem you're encountering,
> and what compiler you're using. The code compiles cleanly for me.

complete code:
http://tim.klingt.org/git?p=boost.git;a=blob;f=libs/smart_ptr/test/
shared_from_this_test.cpp

tested compilers: g++-4.0, 4.1, 4.2, 4.3 ... linux, x86, x86_64

error message:
tim_at_laptop:~/workspace/boost.git/libs/smart_ptr/test$ "g++-4.3" -ftemplate-depth-128 -O0 -fno-inline -Wall -g -fPIC -Wno-non-virtual-dtor -DBOOST_ALL_NO_LIB=1 -I"../../.." -c -o "../../../bin.v2/libs/smart_ptr/test/shared_from_this_test.test/gcc-4.3/debug/shared_from_this_test.o" "shared_from_this_test.cpp"
../../../boost/shared_ptr.hpp: In member function ‘boost::shared_ptr<T>& boost::shared_ptr<T>::operator=(const boost::shared_ptr<Y>&) [with Y = V, T = W]’:
../../../boost/enable_shared_from_this.hpp:98: instantiated from ‘void boost::enable_shared_from_this<T>::_internal_accept_owner(boost::shared_ptr<Y>&) const [with U = W, T = V]’
../../../boost/shared_ptr.hpp:100: instantiated from ‘void boost::detail::sp_enable_shared_from_this(boost::shared_ptr<Y>*, const boost::enable_shared_from_this<T>*) [with T = V, Y = W]’
../../../boost/shared_ptr.hpp:181: instantiated from ‘boost::shared_ptr<T>::shared_ptr(Y*) [with Y = W, T = W]’
shared_from_this_test.cpp:166: instantiated from here
../../../boost/shared_ptr.hpp:298: error: invalid conversion from ‘V* const’ to ‘W*’

hth, tim

-- 
tim_at_[hidden]
http://tim.klingt.org
Silence is only frightening to people who are compulsively
verbalizing.
  William S. Burroughs

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk