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: unassig...@gcc.gnu.org
        ReportedBy: jordan.delong.s...@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));
}

Reply via email to