[libcxx-commits] [libcxx] [libc++] Avoid type-punning between __value_type and pair (PR #134819)
Nikolas Klauser via libcxx-commits
libcxx-commits at lists.llvm.org
Thu Apr 10 00:46:43 PDT 2025
================
@@ -1276,6 +1267,32 @@ private:
}
_LIBCPP_HIDE_FROM_ABI void __move_assign_alloc(__tree&, false_type) _NOEXCEPT {}
+ template <class _From, __enable_if_t<__is_pair_v<__remove_cvref_t<_From> >, int> = 0>
+ _LIBCPP_HIDE_FROM_ABI static void __assign_value(__get_node_value_type_t<value_type>& __lhs, _From&& __rhs) {
+ using __punned_type = pair<typename _NodeTypes::key_type, typename _NodeTypes::mapped_type>;
+
+ reinterpret_cast<__punned_type&>(__lhs) = reinterpret_cast<__copy_cvref_t<_From, __punned_type>&&>(__rhs);
----------------
philnik777 wrote:
Sorry, I might have misunderstood you. Are you suggesting that I should assign the values individually instead of doing the `reinterpret_cast`?
https://github.com/llvm/llvm-project/pull/134819
More information about the libcxx-commits
mailing list