From 63fef6d33778f72592202a4938ee8f8bbac21951 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Kami=C5=84ski?= Date: Tue, 17 Mar 2026 09:34:37 +0100 Subject: [PATCH] libstdc++: Fix is_explict checks in extents test. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The condition was checking if extents is convertible to index_type, and not the reverse. This patch tests implicit conversion from braced initializer list (to cover multiple arguments) and is_convertible in case of single index. libstdc++-v3/ChangeLog: * testsuite/23_containers/mdspan/extents/ctor_ints.cc: Updated is_explicit, and added more test cases. Reviewed-by: Jonathan Wakely Signed-off-by: Tomasz KamiƄski --- .../23_containers/mdspan/extents/ctor_ints.cc | 20 +++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/libstdc++-v3/testsuite/23_containers/mdspan/extents/ctor_ints.cc b/libstdc++-v3/testsuite/23_containers/mdspan/extents/ctor_ints.cc index fdbcb707bbe..eefeab0e6a0 100644 --- a/libstdc++-v3/testsuite/23_containers/mdspan/extents/ctor_ints.cc +++ b/libstdc++-v3/testsuite/23_containers/mdspan/extents/ctor_ints.cc @@ -24,18 +24,30 @@ static_assert(std::is_constructible_v, #endif // No implicit conversion from integer-like objects. -template - constexpr bool +template + consteval bool is_explicit() { - return std::is_nothrow_constructible_v - && !std::is_convertible_v; + if (!std::is_nothrow_constructible_v) + return false; + if constexpr (sizeof...(RIndicies) == 0) + if (std::is_convertible_v) + return false; + + extern void testConv(ExtentsType); + return !requires (OIndex index, RIndicies... rindicies) + { testConv({index, rindicies...}); }; } static_assert(is_explicit, int>()); static_assert(is_explicit, unsigned int>()); static_assert(is_explicit, int>()); +static_assert(is_explicit, int>()); +static_assert(is_explicit, int, int>()); +static_assert(is_explicit, int, int, int>()); + + constexpr bool test_all() {