public inbox for libstdc++@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jonathan Wakely <jwakely@redhat.com>
To: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org
Subject: [committed] libstdc++: Fix std::format test for strict -std=c++20 mode
Date: Tue, 15 Nov 2022 14:31:45 +0000	[thread overview]
Message-ID: <20221115143145.1155275-1-jwakely@redhat.com> (raw)

Tested x86_64-linux and x86_64-w64-mingw32. Pushed to trunk.

-- >8 --

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>.
---
 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
 }
 
-- 
2.38.1


                 reply	other threads:[~2022-11-15 14:31 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20221115143145.1155275-1-jwakely@redhat.com \
    --to=jwakely@redhat.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=libstdc++@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).