[Bug libstdc++/90943] Visiting inherited variants no longer works in 9.1
redi at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Wed Jun 19 23:48:00 GMT 2019
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90943
Jonathan Wakely <redi at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Component|c++ |libstdc++
--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> ---
This is all it takes to compile your example:
--- a/libstdc++-v3/include/std/variant
+++ b/libstdc++-v3/include/std/variant
@@ -795,7 +795,7 @@ namespace __variant
template <typename _Maybe_variant_cookie, typename _Variant>
struct _Extra_visit_slot_needed
{
- template <typename> struct _Variant_never_valueless;
+ template <typename> struct _Variant_never_valueless : false_type { };
template <typename... _Types>
struct _Variant_never_valueless<variant<_Types...>>
This just assumes that unrecognized types are not never-valueless variants,
which means some extra code gets generated to handle the valueless case even if
your variant base class will never be valueless.
I haven't considered if anything else would break by doing that.
More information about the Gcc-bugs
mailing list