problem with shared_from_this in trunk

hi all, a few days ago, some changes to the shared_from_this implementation have been committed to the trunk ... 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); } best, tim -- tim@klingt.org http://tim.klingt.org Most of the trouble in this world has been caused by folks who can't mind their own business, because they have no business of their own to mind, any more than a smallpox virus has. William S. Burroughs

-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On Monday 24 March 2008 06:53 am, Tim Blechmann wrote:
hi all,
a few days ago, some changes to the shared_from_this implementation have been committed to the trunk ...
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. - -- Frank -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.6 (GNU/Linux) iD8DBQFH57Wo5vihyNWuA4URAuRQAJ9fjFM26ZDKMK3FWD5KWBIXA5oWrQCeKvbM yjRyDvipCSWTXbnG/7EslPE= =sKr/ -----END PGP SIGNATURE-----

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@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@klingt.org http://tim.klingt.org Silence is only frightening to people who are compulsively verbalizing. William S. Burroughs

-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On Monday 24 March 2008 10:36 am, Tim Blechmann wrote:
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
Ah, I'm seeing the problem now. Actually, I was using the wrong include path before. I'll see if I can resolve it. And yes, I agree your test snippet should be added either to shared_from_this_test, or esft_regtest. - -- Frank -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.6 (GNU/Linux) iD8DBQFH58Fh5vihyNWuA4URAlL4AKDMAwGmIHKAyiqHRlVTEJlMIj6BDgCfWJHv CmK/z9CddmDDOiYIiIEcVWU= =ccGT -----END PGP SIGNATURE-----

-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On Monday 24 March 2008 10:36 am, Tim Blechmann wrote:
the changes break the following code, though (maybe this can be added to the shared_from_this_test.cpp test suite?):
I think it is fixed in svn now. - -- Frank -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.6 (GNU/Linux) iD8DBQFH58QZ5vihyNWuA4URAgcaAJ9kI3BX2M1rjch8L+g9f9H1Sa/FxQCfQx5Q 02M3HpcUJR4s5zFWiptYCck= =WHby -----END PGP SIGNATURE-----

On Monday 24 March 2008 10:36 am, Tim Blechmann wrote:
the changes break the following code, though (maybe this can be added to the shared_from_this_test.cpp test suite?):
I think it is fixed in svn now.
yes, it is fixed now ... thanks a lot ... cheers, tim -- tim@klingt.org http://tim.klingt.org A paranoid is a man who knows a little of what's going on. William S. Burroughs

Frank Mori Hess:
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
On Monday 24 March 2008 10:36 am, Tim Blechmann wrote:
the changes break the following code, though (maybe this can be added to the shared_from_this_test.cpp test suite?):
I think it is fixed in svn now.
I fixed your fix a bit... can you please take a look to make sure I haven't broken anything.

-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On Monday 24 March 2008 12:03 pm, Peter Dimov wrote:
I fixed your fix a bit... can you please take a look to make sure I haven't broken anything.
Using the aliasing constructor does seem more appropriate than a cast, it looks fine to me. - -- Frank -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.6 (GNU/Linux) iD8DBQFH5+Hn5vihyNWuA4URAtzOAKC5IvqYJg0Xk4A4IbfjnV2rGQZdFACfenmC Wpt23J3MyRgBzAgd3j6Hwz8= =AzaV -----END PGP SIGNATURE-----
participants (3)
-
Frank Mori Hess
-
Peter Dimov
-
Tim Blechmann