public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "nickhuang99 at hotmail dot com" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/102728] New: requires statement fails to recognize lambda in unevaluated context Date: Wed, 13 Oct 2021 14:01:38 +0000 [thread overview] Message-ID: <bug-102728-4@http.gcc.gnu.org/bugzilla/> (raw) https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102728 Bug ID: 102728 Summary: requires statement fails to recognize lambda in unevaluated context 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: --- Consider that this snippet of code gives error of no matching specialization which is not rooted from lambda in function parameter, instead it is rooted from "requires" statement violation of lambda in unevaluated-context. The warning about no-return-statement in lambda within requirement exposes this is "requires" issue. #include <concepts> template<class T> concept IsLambda=requires(T t){ {t}->std::convertible_to<decltype(+[]{})>; }; template<IsLambda T> // OK if replace IsLambda with "class" void foo(T t){ t();} template<> void foo<decltype(+[]{})>(decltype(+[]{}) t){ t(); } Also, a proof that this is not lambda-in-function-parameter issue is that you can replace template parameter "IsLambda" in template function declaration with "class" and GCC works fine. Both clang and MSVC++ accepts above code. (https://www.godbolt.org/z/xhW7Tofao) <source>: In substitution of 'template<class T> requires IsLambda<T> void foo(T) [with T = void (*)()]': <source>:12:44: required from here <source>:5:40: warning: no return statement in function returning non-void [-Wreturn-type] 5 | {t}->std::convertible_to<decltype(+[]{})>; | ^~~~ <source>:12:6: error: template-id 'foo<void (*)()>' for 'void foo(void (*)())' does not match any template declaration 12 | void foo<decltype(+[]{})>(decltype(+[]{}) t){ | ^~~~~~~~~~~~~~~~~~~~ <source>:9:6: note: candidate is: 'template<class T> requires IsLambda<T> void foo(T)' 9 | void foo(T t){ t();} | ^~~
next reply other threads:[~2021-10-13 14:01 UTC|newest] Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top 2021-10-13 14:01 nickhuang99 at hotmail dot com [this message] 2024-04-13 7:53 ` [Bug c++/102728] " pinskia at gcc dot gnu.org
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-102728-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).