[cfe-dev] libc++ and clang++3.2: cannot have make_shared work properly

Akim Demaille akim.demaille at gmail.com
Mon Jun 11 09:37:02 PDT 2012


Hi all,

Using clang++ 3.2 and libc++ from MacPorts, I can't use make_shared.
Maybe I missed something?

$ cat foo.cc
#include <memory>

int
main()
{
  std::make_shared<int>(1);
}
$ clang++-mp-3.2 --version
clang version 3.2 (trunk 157234)
Target: x86_64-apple-darwin11.4.0
Thread model: posix
$ clang++-mp-3.2 -Wall -std=c++11 -stdlib=libc++ foo.cc
In file included from foo.cc:1:
/usr/include/c++/v1/memory:1815:31: error: constructor cannot be redeclared
    _LIBCPP_INLINE_VISIBILITY __libcpp_compressed_pair_imp(_T1_param __t1, _T2_param __t2)
                              ^
/usr/include/c++/v1/memory:1919:15: note: in instantiation of template class 'std::__1::__libcpp_compressed_pair_imp<std::__1::allocator<int>, int, 1>' requested here
    : private __libcpp_compressed_pair_imp<_T1, _T2>
              ^
/usr/include/c++/v1/memory:2641:36: note: in instantiation of template class 'std::__1::__compressed_pair<std::__1::allocator<int>, int>' requested here
    __compressed_pair<_Alloc, _Tp> __data_;
                                   ^
/usr/include/c++/v1/memory:3114:26: note: in instantiation of template class 'std::__1::__shared_ptr_emplace<int, std::__1::allocator<int>>' requested here
    ::new(__hold2.get()) _CntrlBlk(__a2, _STD::forward<_Args>(__args)...);
                         ^
/usr/include/c++/v1/memory:3429:12: note: in instantiation of function template specialization 'std::__1::shared_ptr<int>::make_shared<int>' requested here
    return shared_ptr<_Tp>::make_shared(_STD::forward<_Args>(__args)...);
           ^
foo.cc:6:3: note: in instantiation of function template specialization 'std::__1::make_shared<int, int>' requested here
  std::make_shared<int>(1);
  ^
/usr/include/c++/v1/memory:1811:40: note: previous declaration is here
    _LIBCPP_INLINE_VISIBILITY explicit __libcpp_compressed_pair_imp(_T1_param __t1, int = 0)
                                       ^
/usr/include/c++/v1/memory:1937:31: error: constructor cannot be redeclared
    _LIBCPP_INLINE_VISIBILITY __compressed_pair(_T1_param __t1, _T2_param __t2)
                              ^
/usr/include/c++/v1/memory:2641:36: note: in instantiation of template class 'std::__1::__compressed_pair<std::__1::allocator<int>, int>' requested here
    __compressed_pair<_Alloc, _Tp> __data_;
                                   ^
/usr/include/c++/v1/memory:3114:26: note: in instantiation of template class 'std::__1::__shared_ptr_emplace<int, std::__1::allocator<int>>' requested here
    ::new(__hold2.get()) _CntrlBlk(__a2, _STD::forward<_Args>(__args)...);
                         ^
/usr/include/c++/v1/memory:3429:12: note: in instantiation of function template specialization 'std::__1::shared_ptr<int>::make_shared<int>' requested here
    return shared_ptr<_Tp>::make_shared(_STD::forward<_Args>(__args)...);
           ^
foo.cc:6:3: note: in instantiation of function template specialization 'std::__1::make_shared<int, int>' requested here
  std::make_shared<int>(1);
  ^
/usr/include/c++/v1/memory:1933:40: note: previous declaration is here
    _LIBCPP_INLINE_VISIBILITY explicit __compressed_pair(_T1_param __t1, int = 0)
                                       ^
2 errors generated.
$





More information about the cfe-dev mailing list