[libcxx-commits] [libcxx] [libcxx] implement LWG4148: unique_ptr::operator* should not allow dangling references (PR #128213)

via libcxx-commits libcxx-commits at lists.llvm.org
Fri Feb 21 10:31:15 PST 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 73ad78cc57e10b932bddaa9034237f59bb566e6b 8f7bec983b551545885752bf960d49dcbe05b0dc --extensions h,cpp -- libcxx/test/libcxx/memory/unique_ptr.compile.fail.cpp libcxx/include/__memory/unique_ptr.h
``````````

</details>

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

``````````diff
diff --git a/libcxx/include/__memory/unique_ptr.h b/libcxx/include/__memory/unique_ptr.h
index 5e8335e971..1f0c639391 100644
--- a/libcxx/include/__memory/unique_ptr.h
+++ b/libcxx/include/__memory/unique_ptr.h
@@ -262,7 +262,7 @@ public:
 
   _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 __add_lvalue_reference_t<_Tp> operator*() const
       _NOEXCEPT_(_NOEXCEPT_(*std::declval<pointer>()))
-    // TODO: use reference_converts_from_temporary_v once implemented.
+      // TODO: use reference_converts_from_temporary_v once implemented.
     requires(!__reference_converts_from_temporary(__add_lvalue_reference_t<_Tp>, decltype(*declval<pointer>())))
   {
     return *__ptr_;
diff --git a/libcxx/test/libcxx/memory/unique_ptr.compile.fail.cpp b/libcxx/test/libcxx/memory/unique_ptr.compile.fail.cpp
index 633247da3a..c42af35fce 100644
--- a/libcxx/test/libcxx/memory/unique_ptr.compile.fail.cpp
+++ b/libcxx/test/libcxx/memory/unique_ptr.compile.fail.cpp
@@ -18,7 +18,7 @@ struct deleter {
   void operator()(pointer) const {}
 };
 
-int main(int argc, char const *argv[]) {
+int main(int argc, char const* argv[]) {
   long l = 0;
   std::unique_ptr<const int, deleter> p(&l);
   // Error: indirection requires pointer operand ('std::unique_ptr<const int, deleter>' invalid)

``````````

</details>


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


More information about the libcxx-commits mailing list