[libcxx-commits] [libcxx] [libc++] Remove UB from `std::map` by updating `std::__tree_node` construction (PR #153908)

Vinay Deshmukh via libcxx-commits libcxx-commits at lists.llvm.org
Sat Sep 6 07:15:35 PDT 2025


================
@@ -166,7 +166,12 @@ public:
   }
 #endif
 
-  _LIBCPP_HIDE_FROM_ABI explicit __hash_node(__next_pointer __next, size_t __hash) : _Base(__next), __hash_(__hash) {}
+  template <class _Alloc, class... _Args>
+  _LIBCPP_HIDE_FROM_ABI explicit __hash_node(__next_pointer __next, size_t __hash, _Alloc& __na, _Args&&... __args)
+      : _Base(__next), __hash_(__hash) {
+    allocator_traits<_Alloc>::construct(__na, std::addressof(__get_value()), std::forward<_Args>(__args)...);
+  }
+
   _LIBCPP_HIDE_FROM_ABI ~__hash_node() {}
----------------
vinay-deshmukh wrote:

Should this be changed to `= default;` as well? (while I'm changing this code)

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


More information about the libcxx-commits mailing list