public inbox for libstdc++-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r12-1232] libstdc++: Fix return type of ranges::ssize for 128-bit integer [PR 100824]
@ 2021-06-05 10:45 Jonathan Wakely
  0 siblings, 0 replies; only message in thread
From: Jonathan Wakely @ 2021-06-05 10:45 UTC (permalink / raw)
  To: gcc-cvs, libstdc++-cvs

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();
 }


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-06-05 10:45 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-05 10:45 [gcc r12-1232] libstdc++: Fix return type of ranges::ssize for 128-bit integer [PR 100824] Jonathan Wakely

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).