[libcxx-commits] [libcxx] [libc++] Avoid type-punning between __value_type and pair (PR #134819)

via libcxx-commits libcxx-commits at lists.llvm.org
Fri May 16 16:57:42 PDT 2025


cmtice wrote:

I'm also seeing errors like:

libcxx/include/__tree:1292:5: error: const_cast from 'prototemplate::AttributeType_Type' to '__key_type &' (aka 'std::pair<prototemplate::AttributeType_Type, std::string> &') is not allowed
 1292 |     const_cast<__key_type&>(__lhs.first) = const_cast<__copy_cvref_t<_From, __key_type>&&>(__rhs.first);
          |               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
libcxx/include/__tree:1441:7: note: in instantiation of function template specialization 'std::__tree<std::pair<prototemplate::AttributeType_Type, std::string>, std::less<std::pair<prototemplate::AttributeType_Type, std::string>>, std::allocator<std::pair<prototemplate::AttributeType_Type, std::string>>>::__assign_value<const std::pair<prototemplate::AttributeType_Type, std::string> &, 0>' requested here
 1441 |       __assign_value(__cache.__get()->__value_, *__first);
      |       ^
libcxx/include/__tree:1404:5: note: in instantiation of function template specialization 'std::__tree<std::pair<prototemplate::AttributeType_Type, std::string>, std::less<std::pair<prototemplate::AttributeType_Type, std::string>>, std::allocator<std::pair<prototemplate::AttributeType_Type, std::string>>>::__assign_multi<std::__tree_const_iterator<std::pair<prototemplate::AttributeType_Type, std::string>, std::__tree_node<std::pair<prototemplate::AttributeType_Type, std::string>, void *> *, long>>' requested here
 1404 |     __assign_multi(__t.begin(), __t.end());
      |     ^
libcxx/include/set:666:13: note: in instantiation of member function 'std::__tree<std::pair<prototemplate::AttributeType_Type, std::string>, std::less<std::pair<prototemplate::AttributeType_Type, std::string>>, std::allocator<std::pair<prototemplate::AttributeType_Type, std::string>>>::operator=' requested here
  666 |     __tree_ = __s.__tree_;
      |             ^

None of the fixes reference above fixes this issue.

https://github.com/llvm/llvm-project/pull/134819


More information about the libcxx-commits mailing list