From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 38B083858031; Wed, 25 Aug 2021 13:37:00 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 38B083858031 From: "seredinyegor at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/102065] New: [C++20] Substitution failure of function instantiates its argument Date: Wed, 25 Aug 2021 13:36:59 +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.2.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: seredinyegor 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 attachments.created 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: Wed, 25 Aug 2021 13:37:00 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D102065 Bug ID: 102065 Summary: [C++20] Substitution failure of function instantiates its argument Product: gcc Version: 11.2.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: seredinyegor at gmail dot com Target Milestone: --- Created attachment 51356 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=3D51356&action=3Dedit preprocessed file Problem can be reproduced with: - gcc version 11.2.0 (Ubuntu 11.2.0-1ubuntu2) - gcc version 12.0.0 20210825 (experimental) (GCC) Problem doesn't exist in: - gcc version 10.3.0 (Ubuntu 10.3.0-1ubuntu1~20.04) - Ubuntu clang version 13.0.0-++20210823084033+1f0b043ae709-1~exp1~20210823184829.58 CXXFLAGS: -std=3Dc++20 Code: #include void elem_func(int) {} template < typename Sequence, std::invocable SequenceHandler > void func( const Sequence& values, SequenceHandler&& handler, std::enable_if_t, int> =3D 0) { } template < typename T, std::invocable ValueHandler > void func( T value, ValueHandler&& handler, std::enable_if_t, int> =3D 0) { } int main() { func( new int[1], // pointer =3D> 1st func should be called=20 [](auto e) // lambda should be std::invocable =3D> decltype(e= )=3D=3Dint { elem_func(e); // cannot call elem_func if decltype(e)=3D=3Dint*= (2nd func) } ); } Compiler output: sfinae_bug.cpp: In instantiation of =E2=80=98main():: [with= auto:3 =3D int*]=E2=80=99: /usr/include/c++/11/type_traits:2466:26: required by substitution of =E2=80=98template static std::__result_of_succe= ss()((declval<_Args>)()...)), std::__invoke_other> std::__result_of_other_impl::_S_test(int) [with _Fn =3D main()::; _Args =3D {int*}]=E2=80=99 /usr/include/c++/11/type_traits:2477:55: required from =E2=80=98struct std::__result_of_impl, int*>=E2=80=99 /usr/include/c++/11/type_traits:2937:12: recursively required by substitu= tion of =E2=80=98template struct std::__is_invocable_impl<_Result, _Ret, true, std::__void_t > [with _Result =3D std::__invoke_result, int*>; _Ret =3D void]=E2=80=99 /usr/include/c++/11/type_traits:2937:12: required from =E2=80=98struct std::is_invocable, int*>=E2=80=99 /usr/include/c++/11/type_traits:3001:73: required from =E2=80=98constexpr= const bool std::is_invocable_v, int*>=E2=80=99 /usr/include/c++/11/concepts:338:25: required by substitution of =E2=80=98template requires invocable void func(T, ValueHandler&&, std::enable_if_t<(! is_pointer_v), int>) [w= ith T =3D int*; ValueHandler =3D main()::]=E2=80=99 sfinae_bug.cpp:29:9: required from here sfinae_bug.cpp:33:23: error: invalid conversion from =E2=80=98int*=E2=80=99= to =E2=80=98int=E2=80=99 [-fpermissive] 33 | elem_func(e); // cannot call elem_func if decltype(e)= =3D=3Dint* (2nd func) | ^ | | | int*=