public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "peter.fletcher at bandicootimaging dot com.au" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/111352] New: Inconsistent constructor behavior associated with auto lambda Date: Fri, 08 Sep 2023 23:04:53 +0000 [thread overview] Message-ID: <bug-111352-4@http.gcc.gnu.org/bugzilla/> (raw) https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111352 Bug ID: 111352 Summary: Inconsistent constructor behavior associated with auto lambda Product: gcc Version: 11.4.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: peter.fletcher at bandicootimaging dot com.au Target Milestone: --- Created attachment 55861 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=55861&action=edit Output of gcc -v -save_temps When a constructor involving an auto lambda is called in two different contexts, one triggers a compilation error, one does not. g++ test_bug3.cpp -o test_bug3 -Wall -Wextra test_bug3.cpp: In function ‘int main(int, char**)’: test_bug3.cpp:41:27: error: ‘auto’ parameter not permitted in this context 41 | AA aa(Constructor([&](auto& p) { p.x = 1; })); | ^~~~ Compilation exited abnormally with code 1 at Sat Sep 9 08:50:05 template <typename L> struct Constructor { const L& lambda; Constructor(const L& lambda) : lambda(lambda) { } template <typename T> operator T () const { T out; lambda(out); return out; } }; struct A { int x; }; struct AA { int x{0}; AA() { } AA(A op) : x(op.x) { } }; int main(int argc, char* argv[]) { AA aa(Constructor([&](auto& p) { p.x = 1; })); AA bb = AA(Constructor([&](auto& p) { p.x = 1; })); return aa.x+bb.x+argc+argv[0][0]; }
next reply other threads:[~2023-09-08 23:04 UTC|newest] Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top 2023-09-08 23:04 peter.fletcher at bandicootimaging dot com.au [this message] 2023-09-08 23:07 ` [Bug c++/111352] " peter.fletcher at bandicootimaging dot com.au 2023-09-08 23:12 ` pinskia at gcc dot gnu.org 2023-09-09 5:53 ` pinskia at gcc dot gnu.org 2023-09-09 5:55 ` 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-111352-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).