[libcxx-commits] [libcxx] [libc++] Remove UB from `std::map` by updating `std::__tree_node` construction (PR #153908)
A. Jiang via libcxx-commits
libcxx-commits at lists.llvm.org
Sun Sep 7 08:41:30 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() {}
----------------
frederick-vs-ja wrote:
A defaulted definition is possibly deleted because `__node_value_type` can be non-trivially destructible. I haven't check whether there's any code destroying the `__hash_node` as a whole (i.e. calling the destructor). If so, we shouldn't default it.
https://github.com/llvm/llvm-project/pull/153908
More information about the libcxx-commits
mailing list