C++ PATCH for c++/52026 (use of enclosing constant var in lambda)
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...
Size: 1490 bytes
Desc: not available
More information about the Gcc-patches