https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100384
--- Comment #8 from CVS Commits <cvs-commit at gcc dot gnu.org> --- The releases/gcc-11 branch has been updated by Jonathan Wakely <r...@gcc.gnu.org>: https://gcc.gnu.org/g:e99763ee6da8e378073b847243d9ac2538903534 commit r11-8363-ge99763ee6da8e378073b847243d9ac2538903534 Author: Jonathan Wakely <jwak...@redhat.com> Date: Tue May 4 12:16:46 2021 +0100 libstdc++: Do not use deduced return type for std::visit [PR 100384] This avoids errors outside the immediate context when std::visit is an overload candidate because of ADL, but not actually viable. The solution is to give std::visit a non-deduced return type. New helpers are introduced for that, and existing ones refactored slightly. libstdc++-v3/ChangeLog: PR libstdc++/100384 * include/std/variant (__get_t): New alias template yielding the return type of std::get<N> on a variant. (__visit_result_t): New alias template yielding the result of std::visit. (__same_types): Move into namespace __detail::__variant. (__check_visitor_results): Likewise. Use __invoke_result_t and __get_t. (__check_visitor_result): Remove. (visit): Use __visit_result_t for return type. * testsuite/20_util/variant/100384.cc: New test. (cherry picked from commit af5b2b911dd80ae9cc87404b7e7ab807cf6655d4)