diff --git a/libcxx/include/__memory/pointer_traits.h b/libcxx/include/__memory/pointer_traits.h --- a/libcxx/include/__memory/pointer_traits.h +++ b/libcxx/include/__memory/pointer_traits.h @@ -173,7 +173,7 @@ } // enable_if is needed here to avoid instantiating checks for fancy pointers on raw pointers -template ::value> > +template ::value && !is_array<_Pointer>::value> > _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR typename decay::__call(declval()))>::type __to_address(const _Pointer& __p) _NOEXCEPT { @@ -199,6 +199,12 @@ }; #if _LIBCPP_STD_VER > 17 +template +inline _LIBCPP_INLINE_VISIBILITY constexpr +auto to_address(_Tp *__p) noexcept { + return _VSTD::__to_address(__p); +} + template inline _LIBCPP_INLINE_VISIBILITY constexpr auto to_address(const _Pointer& __p) noexcept { diff --git a/libcxx/test/libcxx/utilities/memory/pointer.conversion/to_address.pass.cpp b/libcxx/test/libcxx/utilities/memory/pointer.conversion/to_address.pass.cpp --- a/libcxx/test/libcxx/utilities/memory/pointer.conversion/to_address.pass.cpp +++ b/libcxx/test/libcxx/utilities/memory/pointer.conversion/to_address.pass.cpp @@ -137,6 +137,14 @@ assert(std::__to_address(p8b) == p8_nil); ASSERT_SAME_TYPE(decltype(std::__to_address(p8b)), decltype(p8_nil)); + int p9[2] = {}; + assert(std::__to_address(p9) == p9); + ASSERT_SAME_TYPE(decltype(std::__to_address(p9)), int*); + + const int p10[2] = {}; + assert(std::__to_address(p10) == p10); + ASSERT_SAME_TYPE(decltype(std::__to_address(p10)), const int*); + return true; } 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 --- a/libcxx/test/std/utilities/memory/pointer.conversion/to_address.pass.cpp +++ b/libcxx/test/std/utilities/memory/pointer.conversion/to_address.pass.cpp @@ -139,6 +139,14 @@ assert(std::to_address(p8b) == p8_nil); ASSERT_SAME_TYPE(decltype(std::to_address(p8b)), decltype(p8_nil)); + int p9[2] = {}; + assert(std::to_address(p9) == p9); + ASSERT_SAME_TYPE(decltype(std::to_address(p9)), int*); + + const int p10[2] = {}; + assert(std::to_address(p10) == p10); + ASSERT_SAME_TYPE(decltype(std::to_address(p10)), const int*); + return true; }