[Bug libstdc++/90943] Visiting inherited variants no longer works in 9.1
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90943 Jonathan Wakely changed: What|Removed |Added Status|NEW |RESOLVED Resolution|--- |FIXED --- Comment #12 from Jonathan Wakely --- Fixed for 11.3
[Bug libstdc++/90943] Visiting inherited variants no longer works in 9.1
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90943 --- Comment #11 from CVS Commits --- The releases/gcc-11 branch has been updated by Jonathan Wakely : https://gcc.gnu.org/g:90b94ca5a2ddd7834afff9ad5e1afff5554e0752 commit r11-9831-g90b94ca5a2ddd7834afff9ad5e1afff5554e0752 Author: Jonathan Wakely Date: Mon Apr 19 14:49:12 2021 +0100 libstdc++: Allow visiting inherited variants [PR 90943] Implement the changes from P2162R2 (as a DR for C++17). Signed-off-by: Jonathan Wakely libstdc++-v3/ChangeLog: PR libstdc++/90943 * include/std/variant (__cpp_lib_variant): Update value. (__detail::__variant::__as): New helpers implementing the as-variant exposition-only function templates. (visit, visit): Use __as to upcast the variant parameters. * include/std/version (__cpp_lib_variant): Update value. * testsuite/20_util/variant/visit_inherited.cc: New test. (cherry picked from commit c46ecb0112e91c80ee111439e79a58a953e4479d)
[Bug libstdc++/90943] Visiting inherited variants no longer works in 9.1
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90943 Jonathan Wakely changed: What|Removed |Added Target Milestone|--- |11.3 --- Comment #10 from Jonathan Wakely --- Done for GCC 12, but I intend to backport it.
[Bug libstdc++/90943] Visiting inherited variants no longer works in 9.1
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90943 --- Comment #9 from CVS Commits --- The master branch has been updated by Jonathan Wakely : https://gcc.gnu.org/g:c46ecb0112e91c80ee111439e79a58a953e4479d commit r12-4067-gc46ecb0112e91c80ee111439e79a58a953e4479d Author: Jonathan Wakely Date: Mon Apr 19 14:49:12 2021 +0100 libstdc++: Allow visiting inherited variants [PR 90943] Implement the changes from P2162R2 (as a DR for C++17). Signed-off-by: Jonathan Wakely libstdc++-v3/ChangeLog: PR libstdc++/90943 * include/std/variant (__cpp_lib_variant): Update value. (__detail::__variant::__as): New helpers implementing the as-variant exposition-only function templates. (visit, visit): Use __as to upcast the variant parameters. * include/std/version (__cpp_lib_variant): Update value. * testsuite/20_util/variant/visit_inherited.cc: New test.
[Bug libstdc++/90943] Visiting inherited variants no longer works in 9.1
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90943 --- Comment #8 from Jonathan Wakely --- Corrected URL for downstream fix: https://gitlab.com/jonathan-wakely/gcc/-/commit/486d89e403a18ef78f05f2efb1bc86bbd396899c
[Bug libstdc++/90943] Visiting inherited variants no longer works in 9.1
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90943 --- Comment #7 from Jonathan Wakely --- Implemented downstream: https://gitlab.com/jonathan-wakely/gcc/-/commit/484308ad163862632ae7e710c5d909be385450aa
[Bug libstdc++/90943] Visiting inherited variants no longer works in 9.1
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90943 Jonathan Wakely changed: What|Removed |Added Status|SUSPENDED |NEW --- Comment #6 from Jonathan Wakely --- http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2021/p2162r2.html says we should support inherited variants.
[Bug libstdc++/90943] Visiting inherited variants no longer works in 9.1
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90943 Jonathan Wakely changed: What|Removed |Added Target Milestone|9.4 |---
[Bug libstdc++/90943] Visiting inherited variants no longer works in 9.1
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90943 Jakub Jelinek changed: What|Removed |Added Target Milestone|9.3 |9.4 --- Comment #5 from Jakub Jelinek --- GCC 9.3.0 has been released, adjusting target milestone.
[Bug libstdc++/90943] Visiting inherited variants no longer works in 9.1
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90943 Jakub Jelinek changed: What|Removed |Added Target Milestone|9.2 |9.3 --- Comment #4 from Jakub Jelinek --- GCC 9.2 has been released.
[Bug libstdc++/90943] Visiting inherited variants no longer works in 9.1
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90943 Jonathan Wakely changed: What|Removed |Added Status|ASSIGNED|SUSPENDED --- Comment #3 from Jonathan Wakely --- https://wg21.link/LWG3052 would forbid us from supporting this.
[Bug libstdc++/90943] Visiting inherited variants no longer works in 9.1
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90943 Jonathan Wakely changed: What|Removed |Added Status|UNCONFIRMED |ASSIGNED Last reconfirmed||2019-06-20 Assignee|unassigned at gcc dot gnu.org |redi at gcc dot gnu.org Target Milestone|--- |9.2 Ever confirmed|0 |1
[Bug libstdc++/90943] Visiting inherited variants no longer works in 9.1
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90943 --- Comment #2 from Barry Revzin --- What if we did something like (using pretty names for a sec): template struct _Extra_visit_slot_needed { template static bool_constant<__never_valueless<_Types...>()> __impl(const variant<_Types...>&); static false_type __impl(...); using _Variant_never_valueless = decltype(__impl(declval<_Variant>())); static constexpr bool value = (is_same_v<_Maybe_variant_cookie, __variant_cookie> || is_same_v<_Maybe_variant_cookie, __variant_idx_cookie>) && !_Variant_never_valueless::value; }; This should (modulo typos) work for real variant instantiations and also anything that inherits from some variant instantiation?
[Bug libstdc++/90943] Visiting inherited variants no longer works in 9.1
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90943 Jonathan Wakely changed: What|Removed |Added Component|c++ |libstdc++ --- Comment #1 from Jonathan Wakely --- 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 struct _Extra_visit_slot_needed { - template struct _Variant_never_valueless; + template struct _Variant_never_valueless : false_type { }; template struct _Variant_never_valueless> 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.