C++ PATCH for c++/52026 (use of enclosing constant var in lambda)
Jason Merrill
jason@redhat.com
Fri Feb 15 04:09:00 GMT 2013
In this testcase, we see a use of a constant variable in a lambda
(though the same thing can happen with a local class member function).
We try to pull out the constant value in finish_id_expression, but
because the initializer isn't a reduced constant yet, that fails and we
end up just returning the variable. At instantiation time tsubst
instantiates the use of the variable by creating a new one in the lambda
context, which is obviously broken. A better solution is to defer
deciding how to handle the variable until instantiation time, at which
point we will know. Since the logic for this is in
finish_id_expression, it's easy to just return the name and look it up
again at that point.
Tested x86_64-pc-linux-gnu, applying to trunk and 4.7.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 52026.patch
Type: text/x-patch
Size: 1490 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20130215/71df61dd/attachment.bin>
More information about the Gcc-patches
mailing list