https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106589
--- Comment #1 from 康桓瑋 <hewillk at gmail dot com> --- variant#L1730: if constexpr (sizeof...(_Variants) == 0) return std::forward<_Visitor>(__visitor)(); In this branch, we seem to need to detect if _Result_type is void and explicitly cast the return type to void.