[Bug c++/96917] decltype(auto) variable initialized with lambda by-reference capture has incorrect type
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96917 --- Comment #5 from Andrey Vihrov --- Thanks!
[Bug c++/96917] decltype(auto) variable initialized with lambda by-reference capture has incorrect type
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96917 Patrick Palka changed: What|Removed |Added Status|NEW |RESOLVED Resolution|--- |FIXED CC||ppalka at gcc dot gnu.org Target Milestone|--- |14.0 Assignee|unassigned at gcc dot gnu.org |ppalka at gcc dot gnu.org --- Comment #4 from Patrick Palka --- Fixed for GCC 14.
[Bug c++/96917] decltype(auto) variable initialized with lambda by-reference capture has incorrect type
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96917 --- Comment #3 from CVS Commits --- The master branch has been updated by Patrick Palka : https://gcc.gnu.org/g:705ab7927c81b77503d229513fac991106617766 commit r14-5330-g705ab7927c81b77503d229513fac991106617766 Author: Patrick Palka Date: Fri Nov 10 10:58:04 2023 -0500 c++: decltype of capture proxy [PR79378, PR96917] We typically don't see capture proxies in finish_decltype_type because process_outer_var_ref is a no-op within an unevaluated context and so a use of a captured variable within decltype resolves to the captured variable, not the capture. But we can see them during decltype(auto) deduction and for decltype of an init-capture, which suggests we need to handle capture proxies specially within finish_decltype_type after all. This patch adds such handling. PR c++/79378 PR c++/96917 gcc/cp/ChangeLog: * semantics.cc (finish_decltype_type): Handle an id-expression naming a capture proxy specially. gcc/testsuite/ChangeLog: * g++.dg/cpp1y/decltype-auto7.C: New test. * g++.dg/cpp1y/lambda-init20.C: New test. Reviewed-by: Jason Merrill
[Bug c++/96917] decltype(auto) variable initialized with lambda by-reference capture has incorrect type
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96917 Guillaume Racicot changed: What|Removed |Added CC||gufideg at gmail dot com --- Comment #2 from Guillaume Racicot --- Seems this bug also apply to deduced return type: template void foo(); void bar() { int i; auto l = []() -> decltype(auto) { foo(); return i; }; l(); foo(); } Yield the assembly: bar(): sub rsp, 8 callvoid foo() add rsp, 8 jmp void foo() Strangely, replacing the return expression to `return static_cast(i);` seems to fix the behaviour.
[Bug c++/96917] decltype(auto) variable initialized with lambda by-reference capture has incorrect type
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96917 Andrew Pinski changed: What|Removed |Added Blocks||54367 Ever confirmed|0 |1 Last reconfirmed||2021-08-03 Status|UNCONFIRMED |NEW --- Comment #1 from Andrew Pinski --- Confirmed. Referenced Bugs: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=54367 [Bug 54367] [meta-bug] lambda expressions