[cfe-dev] [libc++] clang / libc++ fail to compile the code with boost

Douglas Gregor dgregor at apple.com
Sat Jul 2 08:10:18 PDT 2011


On Jul 1, 2011, at 7:55 PM, Eli Friedman wrote:

> On Fri, Jul 1, 2011 at 7:09 PM, ryuuta <ryuuta at gmail.com> wrote:
>> Hi,
>> I bet the problem is in boost implementation but
>> I'm not 100% sure whether the issue is really on boost side or not.
>> Compiling the following code
>> $ cat boost_thread.cpp
>> #include <boost/thread.hpp>
>> int main()
>> {
>>   return 0;
>> }
>> $ clang++ -stdlib=libc++ ./boost_thread.cpp
>> In file included from ./boost_thread.cpp:1:
>> In file included from /usr/include/boost/thread.hpp:24:
>> In file included from /usr/include/boost/thread/future.hpp:14:
>> In file included from /usr/include/boost/exception_ptr.hpp:9:
>> In file included from
>> /usr/include/boost/exception/detail/exception_ptr.hpp:19:
>> In file included from /usr/include/boost/exception/info.hpp:15:
>> In file included from /usr/include/boost/exception/to_string_stub.hpp:15:
>> In file included from
>> /usr/include/boost/exception/detail/object_hex_dump.hpp:14:
>> /usr/include/boost/exception/detail/type_info.hpp:53:9: error: cannot define
>> the implicit default assignment operator for
>>       'boost::exception_detail::type_info_', because non-static reference
>> member 'type_' can't use default assignment operator
>>         type_info_
>>         ^
>> /usr/include/c++/v1/__tree:1244:35: note: in instantiation of member
>> function 'std::__1::pair<boost::exception_detail::type_info_,
>>       boost::shared_ptr<boost::exception_detail::error_info_base>
>>> ::operator=' requested here
>>                 __cache->__value_ = *__first;
>>                                   ^
>> /usr/include/c++/v1/__tree:1185:9: note: in instantiation of function
>> template specialization
>>       'std::__1::__tree<std::__1::pair<boost::exception_detail::type_info_,
>> boost::shared_ptr<boost::exception_detail::error_info_base> >,
>>       std::__1::__map_value_compare<boost::exception_detail::type_info_,
>> boost::shared_ptr<boost::exception_detail::error_info_base>,
>>       std::__1::less<boost::exception_detail::type_info_>, true>,
>> std::__1::allocator<std::__1::pair<boost::exception_detail::type_info_,
>>       boost::shared_ptr<boost::exception_detail::error_info_base> > >
>> 
>>> ::__assign_multi<std::__1::__tree_const_iterator<std::__1::pair<boost::exception_detail::type_info_,
>>       boost::shared_ptr<boost::exception_detail::error_info_base> >, const
>> std::__1::__tree_node<std::__1::pair<boost::exception_detail::type_info_,
>>       boost::shared_ptr<boost::exception_detail::error_info_base> >, void *>
>> *, long> >' requested here
>>         __assign_multi(__t.begin(), __t.end());
>>         ^
>> /usr/include/c++/v1/map:760:21: note: in instantiation of member function
>> 'std::__1::__tree<std::__1::pair<boost::exception_detail::type_info_,
>>       boost::shared_ptr<boost::exception_detail::error_info_base> >,
>> std::__1::__map_value_compare<boost::exception_detail::type_info_,
>>       boost::shared_ptr<boost::exception_detail::error_info_base>,
>> std::__1::less<boost::exception_detail::type_info_>, true>,
>> 
>> std::__1::allocator<std::__1::pair<boost::exception_detail::type_info_,
>> boost::shared_ptr<boost::exception_detail::error_info_base> > >
>>> ::operator='
>>       requested here
>>             __tree_ = __m.__tree_;
>>                     ^
>> /usr/include/boost/exception/info.hpp:160:26: note: in instantiation of
>> member function 'std::__1::map<boost::exception_detail::type_info_,
>>       boost::shared_ptr<boost::exception_detail::error_info_base>,
>> std::__1::less<boost::exception_detail::type_info_>,
>>       std::__1::allocator<std::__1::pair<const
>> boost::exception_detail::type_info_,
>> boost::shared_ptr<boost::exception_detail::error_info_base> > >
>>       >::operator=' requested here
>>                 c->info_ = info_;
>>                          ^
>> /usr/include/boost/exception/detail/type_info.hpp:55:41: note: declared here
>>             detail::sp_typeinfo const & type_;
>>                                         ^
>> /usr/include/c++/v1/utility:247:15: note: implicit default copy assignment
>> operator for 'boost::exception_detail::type_info_' first required here
>>         first = __p.first;
>>               ^
>> 1 error generated.
>> ===================================
>> Since
>> $ clang++ -stdlib=libstdc++ ./boost_thread.cpp
>> has worked perfectly fine my guess is that boost_thread.hpp doesn't strictly
>> conform to the standard.
>> Any comment will be appreciated.
>> Thanks,
>> Ryuta
>> p.s.
>> My boost library is 1.46.1.
> 
> Testcase without boost:
> 
> #include <map>
> struct A { int& x; explicit A(int); public: bool operator<(const A&
> other) const {return x < other.x; }};
> void f(A* x) { std::map<A, int> y, z; z = y; }
> 
> This looks like a boost bug to me... as far as I can tell, the Key
> type of an std::map is required to be assignable if you're assigning
> one map to another (although the implementation isn't required to
> actually use that assignment operator).


C++0x [container.requirements.general] is fairly clear that assigning a container requires the element type to be move assignable. This is a Boost bug.

	- Doug




More information about the cfe-dev mailing list