[libcxx-commits] [libcxx] [libc++] Fix a segfault in weak_ptr(const weak_ptr<Y>&) (PR #67956)

via libcxx-commits libcxx-commits at lists.llvm.org
Mon Oct 2 00:48:03 PDT 2023


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 75441a684273268ce91036aa2c770e669d39f501 6d7d0d3bf981b3c23e75e5e0bb4bb4ed331da8f5 -- libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.const/pr40459.pass.cpp
``````````

</details>

<details>
<summary>
View the diff from clang-format here.
</summary>

``````````diff
diff --git a/libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.const/pr40459.pass.cpp b/libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.const/pr40459.pass.cpp
index 25141ad2de6c..e94104fe8aa8 100644
--- a/libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.const/pr40459.pass.cpp
+++ b/libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.const/pr40459.pass.cpp
@@ -43,10 +43,10 @@ int main(int, char**) {
 #else
   std::aligned_storage<sizeof(B), std::alignment_of<B>::value>::type buffer;
 #endif
-  B *pb = ::new ((void*)&buffer) B();
+  B* pb                 = ::new ((void*)&buffer) B();
   std::shared_ptr<B> sp = std::shared_ptr<B>(pb, Deleter());
-  std::weak_ptr<B> wp = sp;
-  sp = nullptr;
+  std::weak_ptr<B> wp   = sp;
+  sp                    = nullptr;
   assert(wp.expired());
 
   // Overwrite the B object with junk.

``````````

</details>


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


More information about the libcxx-commits mailing list