public inbox for libstdc++-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r11-4024] libstdc++: Fix visitor return type diagnostics [PR97449]
@ 2020-10-17 20:11 Ville Voutilainen
0 siblings, 0 replies; only message in thread
From: Ville Voutilainen @ 2020-10-17 20:11 UTC (permalink / raw)
To: gcc-cvs, libstdc++-cvs
https://gcc.gnu.org/g:1f65bf2aa65609c0cd88af1b83191d37d6729f46
commit r11-4024-g1f65bf2aa65609c0cd88af1b83191d37d6729f46
Author: Ville Voutilainen <ville.voutilainen@gmail.com>
Date: Sat Oct 17 22:08:50 2020 +0300
libstdc++: Fix visitor return type diagnostics [PR97449]
libstdc++-v3/ChangeLog:
PR libstdc++/97449
* include/std/variant
(__gen_vtable_impl<>::_S_apply_single_alt):
Diagnose visitor return type mismatches here..
(__gen_vtable_impl</*base case*/>::_S_apply):
..not here.
Diff:
---
libstdc++-v3/include/std/variant | 12 +++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)
diff --git a/libstdc++-v3/include/std/variant b/libstdc++-v3/include/std/variant
index a29c5bf513b..17f8bcd638b 100644
--- a/libstdc++-v3/include/std/variant
+++ b/libstdc++-v3/include/std/variant
@@ -960,9 +960,13 @@ namespace __variant
}
else
{
- __element = __gen_vtable_impl<
+ auto __tmp_element = __gen_vtable_impl<
remove_reference_t<decltype(__element)>,
std::index_sequence<__indices..., __index>>::_S_apply();
+ static_assert(is_same_v<_Tp, decltype(__tmp_element)>,
+ "std::visit requires the visitor to have the same "
+ "return type for all alternatives of a variant");
+ __element = __tmp_element;
}
}
};
@@ -1026,10 +1030,8 @@ namespace __variant
std::declval<_Variants>()...))>;
if constexpr (__visit_ret_type_mismatch)
{
- static_assert(!__visit_ret_type_mismatch,
- "std::visit requires the visitor to have the same "
- "return type for all alternatives of a variant");
- return __nonesuch{};
+ struct __cannot_match {};
+ return __cannot_match{};
}
else
return _Array_type{&__visit_invoke};
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2020-10-17 20:11 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-17 20:11 [gcc r11-4024] libstdc++: Fix visitor return type diagnostics [PR97449] Ville Voutilainen
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).