diff --git a/stl/inc/xutility b/stl/inc/xutility index 6176fa1c5cc..a8f41b14b5f 100644 --- a/stl/inc/xutility +++ b/stl/inc/xutility @@ -3246,11 +3246,14 @@ _NODISCARD constexpr const tuple_element_t<_Index, tuple<_Types...>>&& get(const namespace ranges { // clang-format off + template + concept _Uses_nonqualification_pointer_conversion = + is_pointer_v<_From> && is_pointer_v<_To> + && !convertible_to(*)[], remove_pointer_t<_To>(*)[]>; + template concept _Convertible_to_non_slicing = convertible_to<_From, _To> - && !(is_pointer_v> - && is_pointer_v> - && _Not_same_as>, remove_pointer_t>>); + && !_Uses_nonqualification_pointer_conversion, decay_t<_To>>; template concept _Pair_like = !is_reference_v<_Ty> && requires(_Ty __t) { diff --git a/tests/std/tests/P0896R4_ranges_subrange/test.compile.pass.cpp b/tests/std/tests/P0896R4_ranges_subrange/test.compile.pass.cpp index 66a2c6b0656..be0cbaa1d7b 100644 --- a/tests/std/tests/P0896R4_ranges_subrange/test.compile.pass.cpp +++ b/tests/std/tests/P0896R4_ranges_subrange/test.compile.pass.cpp @@ -23,6 +23,12 @@ using std::output_iterator_tag, std::input_iterator_tag, std::forward_iterator_t int main() {} // COMPILE-ONLY +void test_LWG_3470() { + int a[] = {1, 2, 3}; + int* b[] = {&a[2], &a[0], &a[1]}; + [[maybe_unused]] auto c = std::ranges::subrange(b); +} + struct empty {}; namespace test_view_interface {