]> git.ipfire.org Git - thirdparty/gcc.git/commit
c++: constant, array, lambda, template [PR108975]
authorJason Merrill <jason@redhat.com>
Fri, 17 Mar 2023 21:26:40 +0000 (17:26 -0400)
committerJason Merrill <jason@redhat.com>
Tue, 18 Apr 2023 20:44:28 +0000 (16:44 -0400)
commit55ab4606ab1084a55d53184c5cf4543740a7f65d
tree75e3902463740a35d7910a0fb8089f41b8342e50
parent615c48b317397c2dc3d6769954d5c399ea882f7a
c++: constant, array, lambda, template [PR108975]

When a lambda refers to a constant local variable in the enclosing scope, we
tentatively capture it, but if we end up pulling out its constant value, we
go back at the end of the lambda and prune any unneeded captures.  Here
while parsing the template we decided that the dim capture was unneeded,
because we folded it away, but then we brought back the use in the template
trees that try to preserve the source representation with added type info.
So then when we tried to instantiate that use, we couldn't find what it was
trying to use, and crashed.

Fixed by not trying to prune when parsing a template; we'll prune at
instantiation time.

PR c++/108975

gcc/cp/ChangeLog:

* lambda.cc (prune_lambda_captures): Don't bother in a template.

gcc/testsuite/ChangeLog:

* g++.dg/cpp0x/lambda/lambda-const11.C: New test.
gcc/cp/lambda.cc
gcc/testsuite/g++.dg/cpp0x/lambda/lambda-const11.C [new file with mode: 0644]