From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id AB3873858D28; Thu, 10 Feb 2022 08:18:52 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org AB3873858D28 From: "pinskia at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/104470] internal compiler error: Segmentation fault compiling std::variant with -std=c++20 Date: Thu, 10 Feb 2022 08:18:52 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Version: 10.3.0 X-Bugzilla-Keywords: ice-on-invalid-code X-Bugzilla-Severity: normal X-Bugzilla-Who: pinskia at gcc dot gnu.org X-Bugzilla-Status: NEW 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: cf_reconfirmed_on keywords everconfirmed bug_status Message-ID: In-Reply-To: References: 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, 10 Feb 2022 08:18:52 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D104470 Andrew Pinski changed: What |Removed |Added ---------------------------------------------------------------------------- Last reconfirmed| |2022-02-10 Keywords|needs-reduction |ice-on-invalid-code Ever confirmed|0 |1 Status|UNCONFIRMED |NEW --- Comment #3 from Andrew Pinski --- Confirmed, reduced: template class variant { template static constexpr int __accepted_index =3D 0; template using __to_type =3D int; template using __accepted_type =3D __to_type<__accepted_index<_Tp>>; template> variant(_Tp __t) { } }; template struct Foo { T value; }; template using V =3D variant>; V e =3D Foo{1}; ---- CUT ---- So I think in the end this is invalid code as the compiler cannot deduce template arguments for V, even though you would think it should. Note clang does not implement a few C++20 deduction support yet so it rejec= ts it for a few other reasons (alias deduction). But MSVC rejects the original code with the following error message (which seems reasonable): (21): error C2641: cannot deduce template arguments for 'V' (21): error C2783: 'std::variant,Bar> std::variant(_Ty &&) noexcept()': could not deduce template argument for 'T' C:/data/msvc/14.31.31103-Pre/include\variant(1024): note: see declaration of 'std::variant' (21): error C2783: 'std::variant,Bar> std::variant(_Ty &&) noexcept()': could not deduce template argument for 'T' C:/data/msvc/14.31.31103-Pre/include\variant(1024): note: see declaration of 'std::variant' (21): error C2780: 'std::variant,Bar> std::variant(void) noexcept()': expects 0 arguments - 1 provided C:/data/msvc/14.31.31103-Pre/include\variant(1014): note: see declaration of 'std::variant' (21): error C2784: 'std::variant,Bar> std::variant(std::variant,Bar>)': could not deduce template argum= ent for 'std::variant,Bar>' from 'Foo' C:/data/msvc/14.31.31103-Pre/include\variant(1004): note: see declaration of 'std::variant' (21): error C2784: 'std::variant,Bar> std::variant(std::variant,Bar>)': could not deduce template argum= ent for 'std::variant,Bar>' from 'Foo' C:/data/msvc/14.31.31103-Pre/include\variant(1004): note: see declaration of 'std::variant'=