From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 327F33851C07; Thu, 25 Jun 2020 23:40:13 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 327F33851C07 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1593128413; bh=KYcSHIiykNFrUR7nS+c+rb0XDv8e1fqLSNxmiFfNlIo=; h=From:To:Subject:Date:From; b=V3lZcYL+aSY5nVrQ0HhAQ7xe/1b/21dI3+ybhc8W18Yge8eZenNg/nv7ao5IEcm1D selsSMg/kYDif+ADM3asdx+JyR/2WDaw6w3F8UGDy10Csgoa185yf/0sGbYAE4ON0d 0qhRPkutOTxU9N3UD9QlQB4QefKLjFIIcVbcNH+Q= From: "rs2740 at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug libstdc++/95904] New: Improve the diagnostic for conflicting return types in std::visit Date: Thu, 25 Jun 2020 23:40:13 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: libstdc++ X-Bugzilla-Version: 11.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: rs2740 at gmail dot com X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 25 Jun 2020 23:40:13 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D95904 Bug ID: 95904 Summary: Improve the diagnostic for conflicting return types in std::visit Product: gcc Version: 11.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: libstdc++ Assignee: unassigned at gcc dot gnu.org Reporter: rs2740 at gmail dot com Target Milestone: --- std::variant x; std::visit([] (auto i) { return i; }, x); produces a less than ideal error with libstdc++: In file included from :1: /opt/compiler-explorer/gcc-trunk-20200625/include/c++/11.0.0/variant: In instantiation of 'static constexpr auto std::__detail::__variant::__gen_vtable_impl, std::integer_sequence >::_S_apply() [with _Result_type =3D std::__detail::__variant::__deduce_visit_result; _Visitor =3D main()::&&; _Variants =3D {std::variant&}; = long unsigned int ...__indices =3D {1}]': /opt/compiler-explorer/gcc-trunk-20200625/include/c++/11.0.0/variant:962:56= :=20=20 required from 'static constexpr void std::__detail::__variant::__gen_vtable_impl, std::integer_sequence >::_S_apply_single_alt(_Tp&, _Tp*) [with bool __do_cookie =3D false; long unsigned int __index =3D 1; _Tp =3D std::__detail::__variant::_Multi_array (*)(main()::&&, std::variant&)>; _Result_ty= pe =3D std::__detail::__variant::__deduce_visit_result; _Visitor =3D main()::&&; long unsigned int ...__dimensions =3D {2}; _Va= riants =3D {std::variant&}; long unsigned int ...__indices =3D {}]' /opt/compiler-explorer/gcc-trunk-20200625/include/c++/11.0.0/variant:941:48= :=20=20 required from 'constexpr const _Array_type std::__detail::__variant::__gen_vtable, main()::&&, std::variant&>::_S_vtable' /opt/compiler-explorer/gcc-trunk-20200625/include/c++/11.0.0/variant:1685:4= 5:=20=20 required from 'constexpr decltype(auto) std::__do_visit(_Visitor&&, _Varian= ts&& ...) [with _Result_type =3D std::__detail::__variant::__deduce_visit_result= ; _Visitor =3D main()::; _Variants =3D {std::variant&}]' /opt/compiler-explorer/gcc-trunk-20200625/include/c++/11.0.0/variant:1704:3= 5:=20=20 required from 'constexpr decltype(auto) std::visit(_Visitor&&, _Variants&& = ...) [with _Visitor =3D main()::; _Variants =3D {std::variant&}]' :5:43: required from here /opt/compiler-explorer/gcc-trunk-20200625/include/c++/11.0.0/variant:1028:6= 7:=20=20 in 'constexpr' expansion of 'std::__detail::__variant::__gen_vtable_impl (*)(main()::&&, std::variant&), 2>, std::integer_sequence >::_S_apply()' /opt/compiler-explorer/gcc-trunk-20200625/include/c++/11.0.0/variant:926:19= :=20=20 in 'constexpr' expansion of 'std::__detail::__variant::__gen_vtable_impl (*)(main()::&&, std::variant&), 2>, std::integer_sequence >::_S_apply_all_alts<0, 1>(__vtabl= e, (std::make_index_sequence<2>(), std::make_index_sequence<2>()))' /opt/compiler-explorer/gcc-trunk-20200625/include/c++/11.0.0/variant:1017:4= 3: error: invalid conversion from 'std::__success_type::type (*)(main()::&&, std::variant&)' {aka 'long = int (*)(main()::&&, std::variant&)'} to 'std::__detail::__variant::_Multi_array (*)(main()::&&, std::variant&)>::__untag_result (*)(main()::&&, std::variant&)>::element_ty= pe' {aka 'int (*)(main()::&&, std::variant&)'} [-fpermissive] 1017 | { return _Array_type{&__visit_invoke}; } | ^ | | | std::__success_type::type (*)(main()::&&, std::variant&) {= aka long int (*)(main()::&&, std::variant&)} Not only is the error about type mismatch in some function pointer conversi= on deep in the guts of the library, but it even offers a "helpful" option to suppress it with -fpermissive... Both MSVC and libc++ handle this case with a nice static_assert.=