|
Boost : |
From: Frank Mori Hess (frank.hess_at_[hidden])
Date: 2008-04-29 09:02:38
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
I've noticed it is possible to construct a half-empty shared_ptr that has an
empty shared_count but a non-null pointer (brief example program attached).
Perhaps the aliasing constructor, and similarly the shared_count constructor
should do some argument checking?
- --
Frank
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
iD8DBQFIFxx05vihyNWuA4URApYiAJwMZIi0qKWDubA60c9yWyP8S5An2QCeK+es
LAW09je97rpq4qxqTRqVuks=
=h5d6
-----END PGP SIGNATURE-----
--Boundary-00=_0xxFINsi6aiKrPm
Content-Type: text/x-c++src;
charset="utf-8";
name="abomination.cpp"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
filename="abomination.cpp"
#include <boost/shared_ptr.hpp>
#include <iostream>
int main()
{
boost::shared_ptr<int> empty;
int x = 1;
boost::shared_ptr<int> aliased(empty, &x);
std::cout << "aliased use_count = " << aliased.use_count() << std::endl;
std::cout << "aliased get = " << aliased.get() << std::endl;
std::cout << "aliased dereference = " << *aliased << std::endl;
return 0;
}
--Boundary-00=_0xxFINsi6aiKrPm--
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk