public inbox for libstdc++@gcc.gnu.org
 help / color / mirror / Atom feed
* [committed] libstdc++: Fix narrowing conversion in std::visit
@ 2021-10-01 19:42 Jonathan Wakely
  0 siblings, 0 replies; only message in thread
From: Jonathan Wakely @ 2021-10-01 19:42 UTC (permalink / raw)
  To: libstdc++, gcc-patches

[-- Attachment #1: Type: text/plain, Size: 241 bytes --]

Signed-off-by: Jonathan Wakely <jwakely@redhat.com>

libstdc++-v3/ChangeLog:

	* include/std/variant (__do_visit): Use variant_npos instead of
	literal -1 that requires a narrowing conversion.

Tested powerpc64le-linux. Committed to trunk.


[-- Attachment #2: patch.txt --]
[-- Type: text/plain, Size: 1045 bytes --]

commit dc1b29508d765b874372f4b1737ac6dc86962506
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Thu May 20 18:04:16 2021

    libstdc++: Fix narrowing conversion in std::visit
    
    Signed-off-by: Jonathan Wakely <jwakely@redhat.com>
    
    libstdc++-v3/ChangeLog:
    
            * include/std/variant (__do_visit): Use variant_npos instead of
            literal -1 that requires a narrowing conversion.

diff --git a/libstdc++-v3/include/std/variant b/libstdc++-v3/include/std/variant
index ddeefd9b35e..d50c6b7de1d 100644
--- a/libstdc++-v3/include/std/variant
+++ b/libstdc++-v3/include/std/variant
@@ -1830,7 +1830,8 @@ namespace __variant
 		  if constexpr (is_same_v<_Result_type, __variant_idx_cookie>
 				|| is_same_v<_Result_type, __variant_cookie>)
 		    {
-		      return __gen_vtable_impl<_Ma, index_sequence<-1>>::
+		      using _Npos = index_sequence<variant_npos>;
+		      return __gen_vtable_impl<_Ma, _Npos>::
 			__visit_invoke(std::forward<_Visitor>(__visitor),
 				       std::forward<_V0>(__v0));
 		    }

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

only message in thread, other threads:[~2021-10-01 19:42 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-01 19:42 [committed] libstdc++: Fix narrowing conversion in std::visit 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).