https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88761
--- Comment #6 from Jason Merrill <jason at gcc dot gnu.org> --- Author: jason Date: Fri Feb 8 14:50:03 2019 New Revision: 268702 URL: https://gcc.gnu.org/viewcvs?rev=268702&root=gcc&view=rev Log: PR c++/88761 - ICE with reference capture of constant. Here, we capture nf, then the use of the proxy decays to a constant during semantic processing of +nf. Since we saw some decay from proxy to constant, we walk through the lambda body to see which proxies are still used, but we weren't walking into subtrees of DECL_EXPR at all, so we missed the use of &nf in the initializer of y, and removed the capture. But then at instantiation time we try to use nf, don't have a proxy anymore, and ICE. * lambda.c (mark_const_cap_r): Do walk subtrees of DECL_EXPR for non-proxy decls. Added: branches/gcc-8-branch/gcc/testsuite/g++.dg/cpp1y/lambda-generic-const6.C Modified: branches/gcc-8-branch/gcc/cp/ChangeLog branches/gcc-8-branch/gcc/cp/lambda.c