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]; }