From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 0C4653850414; Sun, 4 Jul 2021 13:12:31 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 0C4653850414 From: "janpmoeller at gmx dot de" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/101315] New: C++20 lambdas in unevaluated context: erroneously fails with "incomplete type" Date: Sun, 04 Jul 2021 13:12:30 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Version: 11.1.1 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: janpmoeller at gmx dot de 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: Sun, 04 Jul 2021 13:12:31 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D101315 Bug ID: 101315 Summary: C++20 lambdas in unevaluated context: erroneously fails with "incomplete type" Product: gcc Version: 11.1.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: janpmoeller at gmx dot de Target Milestone: --- gcc 11.1 and gcc (trunk) fail to compile the following code with --std=3Dc+= +20: (1) //////////////////////////////////////////////////////////////////////////// #include #include template Fn> struct foo_t { foo_t(Ptr ptr) {} }; template using alias =3D foo_t; template auto fun(T const& t) { return alias{t}; } int main() { std::vector v; auto const error =3D fun(v); } ///////////////////////////////////////////////////////////////////////////= ///// Both versions of gcc state: : In function 'int main()': :19:14: error: 'const void error' has incomplete type 19 | auto const error =3D fun(v); | ^~~~~ Compiler returned: 1 The issue seems to somehow be related to the alias. Replacing the definitio= n of fun() with this code results in successful compilation: (2) //////////////////////////////////////////////////////////////////////////// template auto fun(T const& t) { return foo_t{t}; } ///////////////////////////////////////////////////////////////////////////= ///// Specifying the return type of fun() explicitly results in a different error: (3) //////////////////////////////////////////////////////////////////////////// template auto fun(T const& t) -> alias { return alias{t}; } ///////////////////////////////////////////////////////////////////////////= ///// : In function 'int main()': :19:22: error: 'fun' was not declared in this scope 19 | auto const error =3D fun(v); | ^~~ Compiler returned: 1 I believe all three variants to be valid c++20. clang (trunk) compiles versions (1) and (2) of the code, (3) results in a frontend crash (I'm going to file a bug report against clang for that as we= ll. I'll comment it here for reference after I'm done). Also see this link to godbolt: https://godbolt.org/z/r9GMfxzEo=