public inbox for libstdc++-cvs@sourceware.org
help / color / mirror / Atom feed
From: Jonathan Wakely <redi@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org, libstdc++-cvs@gcc.gnu.org
Subject: [gcc r12-1232] libstdc++: Fix return type of ranges::ssize for 128-bit integer [PR 100824]
Date: Sat,  5 Jun 2021 10:45:02 +0000 (GMT)	[thread overview]
Message-ID: <20210605104502.CF77C385141E@sourceware.org> (raw)

https://gcc.gnu.org/g:96963713f6a648a0ed890450e02ebdd8ff583b14

commit r12-1232-g96963713f6a648a0ed890450e02ebdd8ff583b14
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Sat Jun 5 11:42:01 2021 +0100

    libstdc++: Fix return type of ranges::ssize for 128-bit integer [PR 100824]
    
    Signed-off-by: Jonathan Wakely <jwakely@redhat.com>
    
    libstdc++-v3/ChangeLog:
    
            PR libstdc++/100824
            * include/bits/ranges_base.h (_SSize): Return signed type.
            * testsuite/std/ranges/access/ssize.cc: Check with __int128.

Diff:
---
 libstdc++-v3/include/bits/ranges_base.h           |  2 +-
 libstdc++-v3/testsuite/std/ranges/access/ssize.cc | 15 +++++++++++++++
 2 files changed, 16 insertions(+), 1 deletion(-)

diff --git a/libstdc++-v3/include/bits/ranges_base.h b/libstdc++-v3/include/bits/ranges_base.h
index e3c3962bcd9..728d3ad2b25 100644
--- a/libstdc++-v3/include/bits/ranges_base.h
+++ b/libstdc++-v3/include/bits/ranges_base.h
@@ -447,7 +447,7 @@ namespace ranges
 #if defined __STRICT_ANSI__ && defined __SIZEOF_INT128__
 	  // For strict-ansi modes integral<__int128> is false
 	  else if constexpr (__detail::__is_int128<__size_type>)
-	    return static_cast<unsigned __int128>(__size);
+	    return static_cast<__int128>(__size);
 #endif
 	  else // Must be one of __max_diff_type or __max_size_type.
 	    return __detail::__max_diff_type(__size);
diff --git a/libstdc++-v3/testsuite/std/ranges/access/ssize.cc b/libstdc++-v3/testsuite/std/ranges/access/ssize.cc
index f53f462580c..fdbf245d036 100644
--- a/libstdc++-v3/testsuite/std/ranges/access/ssize.cc
+++ b/libstdc++-v3/testsuite/std/ranges/access/ssize.cc
@@ -85,6 +85,20 @@ test06()
   VERIFY( s == 4 );
 }
 
+void
+test07()
+{
+#ifdef __SIZEOF_INT128__
+  struct R
+  {
+    unsigned __int128 size() const { return 4; }
+  };
+  R r;
+  static_assert( std::same_as<decltype(std::ranges::ssize(r)), __int128> );
+  VERIFY( std::ranges::ssize(r) == 4 );
+#endif
+}
+
 int
 main()
 {
@@ -93,4 +107,5 @@ main()
   test04();
   test05();
   test06();
+  test07();
 }


                 reply	other threads:[~2021-06-05 10:45 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=20210605104502.CF77C385141E@sourceware.org \
    --to=redi@gcc.gnu.org \
    --cc=gcc-cvs@gcc.gnu.org \
    --cc=libstdc++-cvs@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).