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

Akim Demaille akim.demaille at gmail.com
Thu Jun 14 08:11:44 PDT 2012


hi Howard,

Thanks for your answer.

Le 14 juin 2012 à 16:48, Howard Hinnant a écrit :

> In C++03 mode make_shared only accepts up to 3 arguments, and they all must be lvalues.  Either do:
> 
>   std::make_shared<int>(i);
> 
> or turn on C++11:  -std=c++11
> 
> Howard

>> $ clang++-mp-3.2 -Wall -std=c++11 -stdlib=libc++ foo.cc

It is on.  If it works for you, then perfect, it just means
that this libc++ is too old.  If nobody has tested on a recent
checkout, then there might be an unresolved bug.

>> 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.
>> $
>> 
>> 
>> _______________________________________________
>> cfe-dev mailing list
>> cfe-dev at cs.uiuc.edu
>> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
> 





More information about the cfe-dev mailing list