[libcxx-commits] [libcxx] [libc++] Add regression test for #67449 (PR #67590)

Louis Dionne via libcxx-commits libcxx-commits at lists.llvm.org
Wed Sep 27 11:57:44 PDT 2023


https://github.com/ldionne created https://github.com/llvm/llvm-project/pull/67590

Even though the underlying issue was fixed in #65177 when we made std::pointer_traits SFINAE-friendly, it is worth adding a regression test since it's so easy to do.

>From e8e3ab570aa00489735141ba7056b27ea03aac6a Mon Sep 17 00:00:00 2001
From: Louis Dionne <ldionne.2 at gmail.com>
Date: Wed, 27 Sep 2023 14:56:33 -0400
Subject: [PATCH] [libc++] Add regression test for #67449

Even though the underlying issue was fixed in #65177 when we made
std::pointer_traits SFINAE-friendly, it is worth adding a regression
test since it's so easy to do.
---
 .../memory/pointer.conversion/to_address.pass.cpp         | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/libcxx/test/std/utilities/memory/pointer.conversion/to_address.pass.cpp b/libcxx/test/std/utilities/memory/pointer.conversion/to_address.pass.cpp
index fea34ffe99de2bd..9ed0eeefcff829c 100644
--- a/libcxx/test/std/utilities/memory/pointer.conversion/to_address.pass.cpp
+++ b/libcxx/test/std/utilities/memory/pointer.conversion/to_address.pass.cpp
@@ -153,6 +153,14 @@ constexpr bool test() {
     assert(std::to_address(&p11) == &p11);
     ASSERT_SAME_TYPE(decltype(std::to_address(&p11)), int(**)());
 
+    // See https://github.com/llvm/llvm-project/issues/67449
+    {
+        struct S { };
+        S* p = nullptr;
+        assert(std::to_address<S>(p) == p);
+        ASSERT_SAME_TYPE(decltype(std::to_address<S>(p)), S*);
+    }
+
     return true;
 }
 



More information about the libcxx-commits mailing list