[gcc r13-4061] libstdc++: Fix std::format test for strict -std=c++20 mode
Jonathan Wakely
redi@gcc.gnu.org
Tue Nov 15 14:29:36 GMT 2022
https://gcc.gnu.org/g:c68c468e0ebb6922816367a06e4ab02bad08eb08
commit r13-4061-gc68c468e0ebb6922816367a06e4ab02bad08eb08
Author: Jonathan Wakely <jwakely@redhat.com>
Date: Tue Nov 15 14:24:57 2022 +0000
libstdc++: Fix std::format test for strict -std=c++20 mode
Adjust a test to avoid using std::make_unsigned_t<__int128>. That's
ill-formed in strict modes because std::is_integral_v<__int128> is
false.
libstdc++-v3/ChangeLog:
* testsuite/std/format/functions/format.cc: Do not use
std::make_unsigned_t<__int128>.
Diff:
---
libstdc++-v3/testsuite/std/format/functions/format.cc | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/libstdc++-v3/testsuite/std/format/functions/format.cc b/libstdc++-v3/testsuite/std/format/functions/format.cc
index c01405eac90..8019fbdf712 100644
--- a/libstdc++-v3/testsuite/std/format/functions/format.cc
+++ b/libstdc++-v3/testsuite/std/format/functions/format.cc
@@ -233,7 +233,7 @@ test_wchar()
void
test_minmax()
{
- auto check = []<typename T>(T) {
+ auto check = []<typename T, typename U = std::make_unsigned_t<T>>(T, U = 0) {
const int digits = std::numeric_limits<T>::digits;
const std::string zeros(digits, '0');
const std::string ones(digits, '1');
@@ -241,7 +241,6 @@ test_minmax()
VERIFY( s == "-1" + zeros );
s = std::format("{:b}" , std::numeric_limits<T>::max());
VERIFY( s == ones );
- using U = std::make_unsigned_t<T>;
s = std::format("{:0{}b}" , std::numeric_limits<U>::min(), digits + 1);
VERIFY( s == '0' + zeros );
s = std::format("{:b}" , std::numeric_limits<U>::max());
@@ -252,7 +251,9 @@ test_minmax()
check(std::int32_t(0));
check(std::int64_t(0));
#ifdef __SIZEOF_INT128__
- check(__int128(0));
+ // std::make_unsigned_t<__int128> is invalid for strict -std=c++20 mode,
+ // so pass a second argument of the unsigned type.
+ check(__int128(0), (unsigned __int128)(0));
#endif
}
More information about the Libstdc++-cvs
mailing list