From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id EF2603858D37; Thu, 3 Feb 2022 01:24:01 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org EF2603858D37 From: "nickhuang99 at hotmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/104358] New: Assignable template lambda as function parameter is incorrectly reduced to type of "int" Date: Thu, 03 Feb 2022 01:24:01 +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: 12.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: nickhuang99 at hotmail 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, 03 Feb 2022 01:24:02 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D104358 Bug ID: 104358 Summary: Assignable template lambda as function parameter is incorrectly reduced to type of "int" Product: gcc Version: 12.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: nickhuang99 at hotmail dot com Target Milestone: --- Please see code at https://www.godbolt.org/z/o3bxxsYPK All other compilers parses this correctly. #include #include using namespace std; //1. I have a callback which happens to be an assignable lambda template using Lambda=3Ddecltype(+[](T){}); // which is esstially a function pointer=20 static_assert(is_same_v, void(*)(int)>); //2. Here is my data handle function which takes a data and the callback=20 template auto foo(T&&, Lambda)->T; //3. However, parser consider the callback as type of "int" static_assert( ! is_same_v), int(*)(int&&, void(*)(int))= >); // lambda type is always considered as "int" static_assert(is_same_v), int(*)(int&&, int)>); static_assert(is_same_v), bool(*)(bool&&, int)>); // this is impossible as callback CANNOT be "int" static_assert( ! is_same_v, int>); //////////////////////////////////////////// //4. This won't happen for a traditional function pointer template using FunPtr=3Dvoid(*)(T); static_assert(is_same_v, void(*)(int)>); //5. let's define a similar function with callback template auto bar(T&&, FunPtr)->T; // there is no way for parser to consider callback as type of "int" static_assert(is_same_v), int(*)(int&&, void(*)(int))>);=