On Wed, 17 Dec 2025 at 21:11 +0000, Jonathan Wakely wrote:
On Wed, 17 Dec 2025 at 21:10, Jonathan Wakely <[email protected]> wrote:

On Wed, 17 Dec 2025 at 20:52, Luc Grosheintz <[email protected]> wrote:
> -constexpr auto i8_6 = int8_t{6};
> -constexpr auto c_i8_6 = std::cw<int8_t{6}>;
> +constexpr auto i8_6 = (signed char){6};
> +constexpr auto c_i8_6 = std::cw<(signed char){6}>;

Actually all these braces should be removed, so just:

(signed char){6} not (signed char){6}, otherwise it's a C99 compound
literal, which is not valid in C++ and will warn with -pedantic.

Gah, pasted the wrong thing. I mean:
(signed char)6 not (signed char){6}

How about doing it like this instead:



Author:     Luc Grosheintz <[email protected]>
AuthorDate: Wed Dec 17 20:54:56 2025

    libstdc++: Fix mdspan tests for Solaris. [PR123176]
On Solaris, same_as<int8_t, char> is true. Therefore, int8_t isn't a
    valid IndexType, because char is neither a signed nor an unsigned
    integer type.
This commit fixes the tests by avoiding int8_t (and uint8_t) by defining
    new aliases for 'signed char' and 'unsigned char'.
PR libstdc++/123176 libstdc++-v3/ChangeLog: * testsuite/23_containers/mdspan/submdspan/submdspan_canonicalize_slices_neg.cc:
            Avoid int8_t with signed char.
Co-authored-by: Joanthan Wakely <[email protected]>
    Signed-off-by: Luc Grosheintz <[email protected]>

diff --git 
a/libstdc++-v3/testsuite/23_containers/mdspan/submdspan/submdspan_canonicalize_slices_neg.cc
 
b/libstdc++-v3/testsuite/23_containers/mdspan/submdspan/submdspan_canonicalize_slices_neg.cc
index 94bca183aa3b..d927cb8f5a01 100644
--- 
a/libstdc++-v3/testsuite/23_containers/mdspan/submdspan/submdspan_canonicalize_slices_neg.cc
+++ 
b/libstdc++-v3/testsuite/23_containers/mdspan/submdspan/submdspan_canonicalize_slices_neg.cc
@@ -3,14 +3,19 @@
#include <cstdint> +
+// int8_t is char on Solaris (see PR libstdc++/123176), so define our own:
+using int8 = signed char;
+using uint8 = unsigned char;
+
 constexpr size_t dyn = std::dynamic_extent;
constexpr auto dyn_empty = std::extents<int32_t, dyn>{0};
 constexpr auto sta_empty = std::extents<uint32_t, 0>{};
-constexpr auto dyn_uexts = std::extents<uint8_t, dyn>{5};
+constexpr auto dyn_uexts = std::extents<uint8, dyn>{5};
 constexpr auto sta_uexts = std::extents<uint16_t, 5>{5};
-constexpr auto dyn_sexts = std::extents<int8_t, dyn>{5};
+constexpr auto dyn_sexts = std::extents<int8, dyn>{5};
 constexpr auto sta_sexts = std::extents<int16_t, 5>{5};
constexpr bool
@@ -69,7 +74,7 @@ template<typename Offset, typename Extent, typename Stride, 
typename Extents>
     return true;
   }
-constexpr auto i8_1 = int8_t{1};
+constexpr auto i8_1 = int8{1};
static_assert(test_under2(-i8_1, 0, 1, dyn_uexts)); // { dg-error "expansion of" }
 static_assert(test_under2(0, -i8_1, 1, dyn_uexts));   // { dg-error "expansion 
of" }
@@ -84,7 +89,7 @@ static_assert(test_under2(-i8_1, 0, 1, sta_sexts));   // { 
dg-error "expansion o
 static_assert(test_under2(0, -i8_1, 1, sta_sexts));   // { dg-error "expansion 
of" }
 static_assert(test_under2(0, 1, -i8_1, sta_sexts));   // { dg-error "expansion 
of" }
-constexpr auto c_i8_m1 = std::cw<int8_t{-1}>;
+constexpr auto c_i8_m1 = std::cw<int8{-1}>;
 constexpr auto c_i16_m1 = std::cw<int16_t{-1}>;
 constexpr auto c_i64_m1 = std::cw<int64_t{-1}>;
@@ -109,8 +114,8 @@ template<typename Offset, typename Extent, typename Stride, typename Extents>
     return true;
   }
-constexpr auto i8_6 = int8_t{6};
-constexpr auto c_i8_6 = std::cw<int8_t{6}>;
+constexpr auto i8_6 = int8{6};
+constexpr auto c_i8_6 = std::cw<int8{6}>;
 constexpr auto c2 = std::cw<2>;
 constexpr auto c4 = std::cw<4>;
@@ -155,7 +160,7 @@ static_assert(test_over2(c2, c4, 1, sta_sexts)); // { dg-error "expansion of
 constexpr bool
 test_overflow1(auto o, auto e)
 {
-  auto exts = std::extents<uint8_t, dyn>{255};
+  auto exts = std::extents<uint8, dyn>{255};
   auto slice = std::strided_slice{o, e, 1};
   std::submdspan_canonicalize_slices(exts, slice);
   return true;
@@ -169,7 +174,7 @@ static_assert(test_overflow1(std::cw<128>, std::cw<128>));  // { 
dg-error "expan
 constexpr bool
 test_overflow2(auto b, auto e)
 {
-  auto exts = std::extents<uint8_t, dyn>{255};
+  auto exts = std::extents<uint8, dyn>{255};
   auto slice = std::pair{b, e};
   std::submdspan_canonicalize_slices(exts, slice);
   return true;
@@ -180,8 +185,8 @@ static_assert(test_overflow2(std::cw<5>, 4));           // { 
dg-error "expansion
 static_assert(test_overflow2(5, std::cw<4>));           // { dg-error "expansion 
of" }
 static_assert(test_overflow2(std::cw<5>, std::cw<4>));  // { dg-error "expansion 
of" }
-constexpr auto u8_4 = uint8_t{4};
-constexpr auto u8_5 = uint8_t{5};
+constexpr auto u8_4 = uint8{4};
+constexpr auto u8_5 = uint8{5};
 static_assert(test_overflow2(u8_5, u8_4));                    // { dg-error 
"expansion of" }
 static_assert(test_overflow2(std::cw<u8_5>, u8_4));           // { dg-error 
"expansion of" }
 static_assert(test_overflow2(u8_5, std::cw<u8_4>));           // { dg-error 
"expansion of" }

Reply via email to