From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id D79983894403; Mon, 3 May 2021 16:07:32 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D79983894403 From: "vopl at bk dot ru" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/100396] [11.1 regression] The template function overload is not selected correctly Date: Mon, 03 May 2021 16:07:32 +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: 11.1.0 X-Bugzilla-Keywords: rejects-valid X-Bugzilla-Severity: normal X-Bugzilla-Who: vopl at bk dot ru X-Bugzilla-Status: RESOLVED X-Bugzilla-Resolution: INVALID 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: 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: Mon, 03 May 2021 16:07:32 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D100396 --- Comment #2 from vopl at bk dot ru --- Please, try this, also failed /////////0/////////1/////////2/////////3/////////4/////////5/////////6/////= ////7 template struct Checker { using Some =3D decltype(F{}(Args{}...)); }; template concept valid =3D requires { typename Checker::Some; }; /////////0/////////1/////////2/////////3/////////4/////////5/////////6/////= ////7 template auto ovr(F f, Args... args) requires valid { return ovr(int{}, f, args...); // a second ovr is expected = to be called, but the compiler tries to call this ovr again. Collision between 'int' and 'F' is ignored, extra Args provided to call } template auto ovr(int, F f, Args... args) { return f(args...); } /////////0/////////1/////////2/////////3/////////4/////////5/////////6/////= ////7 void use() { ovr([]{}); } $ g++-11.1.0 -std=3Dc++20 -c src.cpp=20 src.cpp: In instantiation of 'struct Checker, use():: >': src.cpp:8:25: required by substitution of 'template auto ovr(F, Args ...) requires valid [with F =3D use()::; Args =3D {use()::}]' src.cpp:14:27: required from 'auto ovr(F, Args ...) requires valid [with F =3D use()::; Args =3D {}]' src.cpp:25:8: required from here src.cpp:4:30: error: no match for call to '(use()::) (use()::)' 4 | using Some =3D decltype(F{}(Args{}...)); | ~~~^~~~~~~~~~~ src.cpp:4:30: note: candidate: 'void (*)()' (conversion) src.cpp:4:30: note: candidate expects 1 argument, 2 provided src.cpp:25:9: note: candidate: 'use()::' 25 | ovr([]{}); | ^ src.cpp:25:9: note: candidate expects 0 arguments, 1 provided ---------- IMHO, the problem is not caused by concepts, but caused by corrupted overloading selection mechanic. Please, take a look at the collision between argument 'int{}' and first template parameter specified as 'F'. Next, no SF= INAE expected in this case due to correct overloading, but overloading failed and SFINAE happens. Thanks.=