This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug libstdc++/49925] New: ADL bug mixing boost::shared_ptr and std::make_shared<>
- From: "jordan.delong.spam at gmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Sun, 31 Jul 2011 19:59:02 +0000
- Subject: [Bug libstdc++/49925] New: ADL bug mixing boost::shared_ptr and std::make_shared<>
- Auto-submitted: auto-generated
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49925
Summary: ADL bug mixing boost::shared_ptr and
std::make_shared<>
Product: gcc
Version: unknown
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: libstdc++
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: jordan.delong.spam@gmail.com
libstdc++ implements make_shared in terms of allocate_shared, which exists in
namespace boost (any recent boost version). If you try to use make_shared
passing a boost::shared_ptr<> as an argument, it breaks this due to Koenig
lookup. (Should be simple to fix by explicitly qualifying in the make_shared
implementation or surrounding allocate_shared with parenthesis.)
Repro (in gcc 4.6, boost 1.46). I checked trunk libstdc++ and it looks like
the bug is still there (bits/shared_ptr.h line 610).
#include <boost/shared_ptr.hpp>
#include <boost/make_shared.hpp>
#include <functional>
#include <memory>
struct f {
explicit f(const boost::shared_ptr<int>&) {}
};
int main() {
boost::shared_ptr<int> p;
auto pf = std::make_shared<f>((p));
}