[libcxx-commits] [libcxx] [libc++] Remove UB from std::map __tree_node constructor (PR #153908)
via libcxx-commits
libcxx-commits at lists.llvm.org
Fri Aug 15 17:51:20 PDT 2025
github-actions[bot] wrote:
<!--LLVM CODE FORMAT COMMENT: {clang-format}-->
:warning: C/C++ code formatter, clang-format found issues in your code. :warning:
<details>
<summary>
You can test this locally with the following command:
</summary>
``````````bash
git-clang-format --diff HEAD~1 HEAD --extensions -- libcxx/include/__tree
``````````
</details>
<details>
<summary>
View the diff from clang-format here.
</summary>
``````````diff
diff --git a/libcxx/include/__tree b/libcxx/include/__tree
index d860f4c96..5245dcdb2 100644
--- a/libcxx/include/__tree
+++ b/libcxx/include/__tree
@@ -582,25 +582,25 @@ class _LIBCPP_STANDALONE_DEBUG __tree_node : public __tree_node_base<_VoidPtr> {
public:
using __node_value_type _LIBCPP_NODEBUG = __get_node_value_type_t<_Tp>;
- // We allow starting the lifetime of nodes without initializing the value held by the node,
- // since that is handled by the map itself in order to be allocator-aware.
- # ifndef _LIBCPP_CXX03_LANG
+// We allow starting the lifetime of nodes without initializing the value held by the node,
+// since that is handled by the map itself in order to be allocator-aware.
+#ifndef _LIBCPP_CXX03_LANG
- private:
- union {
- __node_value_type __value_;
- };
+private:
+ union {
+ __node_value_type __value_;
+ };
- public:
- _LIBCPP_HIDE_FROM_ABI __node_value_type& __get_value() { return __value_; }
- # else
+public:
+ _LIBCPP_HIDE_FROM_ABI __node_value_type& __get_value() { return __value_; }
+#else
- private:
- _ALIGNAS_TYPE(__node_value_type) unsigned char __buffer_[sizeof(__node_value_type)];
+private:
+ _ALIGNAS_TYPE(__node_value_type) unsigned char __buffer_[sizeof(__node_value_type)];
- public:
- _LIBCPP_HIDE_FROM_ABI __node_value_type& __get_value() { return *std::__launder(reinterpret_cast<_Tp*>(&__buffer_)); }
- # endif
+public:
+ _LIBCPP_HIDE_FROM_ABI __node_value_type& __get_value() { return *std::__launder(reinterpret_cast<_Tp*>(&__buffer_)); }
+#endif
template <class _Alloc, class... _Args>
explicit __tree_node(_Alloc& __na, _Args&&... __args) {
``````````
</details>
https://github.com/llvm/llvm-project/pull/153908
More information about the libcxx-commits
mailing list