https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106589
--- Comment #5 from CVS Commits <cvs-commit at gcc dot gnu.org> --- The master branch has been updated by Jonathan Wakely <r...@gcc.gnu.org>: https://gcc.gnu.org/g:e85bb1881e57e53306ede2a15f30d06480d69886 commit r13-2157-ge85bb1881e57e53306ede2a15f30d06480d69886 Author: Jonathan Wakely <jwak...@redhat.com> Date: Tue Aug 23 15:46:16 2022 +0100 libstdc++: Fix visit<void>(v) for non-void visitors [PR106589] The optimization for the common case of std::visit forgot to handle the edge case of passing zero variants to a non-void visitor and converting the result to void. libstdc++-v3/ChangeLog: PR libstdc++/106589 * include/std/variant (__do_visit): Handle is_void<R> for zero argument case. * testsuite/20_util/variant/visit_r.cc: Check std::visit<void>(v).