public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "seredinyegor at gmail dot com" <gcc-bugzilla@gcc.gnu.org> 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 [thread overview] Message-ID: <bug-102065-4@http.gcc.gnu.org/bugzilla/> (raw) https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102065 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=51356&action=edit 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=c++20 Code: #include <functional> void elem_func(int) {} template < typename Sequence, std::invocable<int> SequenceHandler > void func( const Sequence& values, SequenceHandler&& handler, std::enable_if_t<std::is_pointer_v<Sequence>, int> = 0) { } template < typename T, std::invocable<T> ValueHandler > void func( T value, ValueHandler&& handler, std::enable_if_t<!std::is_pointer_v<T>, int> = 0) { } int main() { func( new int[1], // pointer => 1st func should be called [](auto e) // lambda should be std::invocable<int> => decltype(e)==int { elem_func(e); // cannot call elem_func if decltype(e)==int* (2nd func) } ); } Compiler output: sfinae_bug.cpp: In instantiation of ‘main()::<lambda(auto:3)> [with auto:3 = int*]’: /usr/include/c++/11/type_traits:2466:26: required by substitution of ‘template<class _Fn, class ... _Args> static std::__result_of_success<decltype (declval<_Fn>()((declval<_Args>)()...)), std::__invoke_other> std::__result_of_other_impl::_S_test(int) [with _Fn = main()::<lambda(auto:3)>; _Args = {int*}]’ /usr/include/c++/11/type_traits:2477:55: required from ‘struct std::__result_of_impl<false, false, main()::<lambda(auto:3)>, int*>’ /usr/include/c++/11/type_traits:2937:12: recursively required by substitution of ‘template<class _Result, class _Ret> struct std::__is_invocable_impl<_Result, _Ret, true, std::__void_t<typename _CTp::type> > [with _Result = std::__invoke_result<main()::<lambda(auto:3)>, int*>; _Ret = void]’ /usr/include/c++/11/type_traits:2937:12: required from ‘struct std::is_invocable<main()::<lambda(auto:3)>, int*>’ /usr/include/c++/11/type_traits:3001:73: required from ‘constexpr const bool std::is_invocable_v<main()::<lambda(auto:3)>, int*>’ /usr/include/c++/11/concepts:338:25: required by substitution of ‘template<class T, class ValueHandler> requires invocable<ValueHandler, T> void func(T, ValueHandler&&, std::enable_if_t<(! is_pointer_v<T>), int>) [with T = int*; ValueHandler = main()::<lambda(auto:3)>]’ sfinae_bug.cpp:29:9: required from here sfinae_bug.cpp:33:23: error: invalid conversion from ‘int*’ to ‘int’ [-fpermissive] 33 | elem_func(e); // cannot call elem_func if decltype(e)==int* (2nd func) | ^ | | | int*
next reply other threads:[~2021-08-25 13:37 UTC|newest] Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top 2021-08-25 13:36 seredinyegor at gmail dot com [this message] 2021-08-25 14:44 ` [Bug c++/102065] " ppalka at gcc dot gnu.org 2021-08-25 18:00 ` seredinyegor at gmail dot com
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=bug-102065-4@http.gcc.gnu.org/bugzilla/ \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).