diff --git a/libcxx/include/__utility/decay_copy.h b/libcxx/include/__utility/decay_copy.h index 5c9716a89279..32238e117f56 100644 --- a/libcxx/include/__utility/decay_copy.h +++ b/libcxx/include/__utility/decay_copy.h @@ -24,7 +24,7 @@ template _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR typename decay<_Tp>::type __decay_copy(_Tp&& __t) #if _LIBCPP_STD_VER > 17 - noexcept(is_nothrow_convertible_v<_Tp, remove_reference_t<_Tp>>) + noexcept(is_nothrow_convertible_v<_Tp, decay_t<_Tp>>) #endif { return _VSTD::forward<_Tp>(__t); diff --git a/libcxx/test/std/ranges/range.access/range.access.begin/begin.pass.cpp b/libcxx/test/std/ranges/range.access/range.access.begin/begin.pass.cpp index 04f30c814359..3b712a1cc137 100644 --- a/libcxx/test/std/ranges/range.access/range.access.begin/begin.pass.cpp +++ b/libcxx/test/std/ranges/range.access/range.access.begin/begin.pass.cpp @@ -264,6 +264,13 @@ ASSERT_NOEXCEPT(std::ranges::cbegin(std::declval&>())); ASSERT_NOT_NOEXCEPT(std::ranges::begin(std::declval>&>())); ASSERT_NOT_NOEXCEPT(std::ranges::cbegin(std::declval>&>())); +struct BeginReturnsArrayRef { + auto begin() const noexcept -> int(&)[10]; + auto end() const noexcept -> int(&)[10]; +} brar; +static_assert(noexcept(std::ranges::begin(brar))); +static_assert(noexcept(std::ranges::cbegin(brar))); + int main(int, char**) { testArray(); diff --git a/libcxx/test/std/ranges/range.access/range.access.end/end.pass.cpp b/libcxx/test/std/ranges/range.access/range.access.end/end.pass.cpp index f860442af4fb..dd5da2ebf594 100644 --- a/libcxx/test/std/ranges/range.access/range.access.end/end.pass.cpp +++ b/libcxx/test/std/ranges/range.access/range.access.end/end.pass.cpp @@ -298,6 +298,13 @@ ASSERT_NOEXCEPT(std::ranges::cend(std::declval&>())); ASSERT_NOT_NOEXCEPT(std::ranges::end(std::declval>&>())); ASSERT_NOT_NOEXCEPT(std::ranges::cend(std::declval>&>())); +struct BeginReturnsArrayRef { + auto begin() const noexcept -> int(&)[10]; + auto end() const noexcept -> int(&)[10]; +} brar; +static_assert(noexcept(std::ranges::end(brar))); +static_assert(noexcept(std::ranges::cend(brar))); + int main(int, char**) { testArray();