Commit 30fa2a51 by Jason Merrill Committed by Jason Merrill

re PR c++/52026 (Constexpr Variable Appears Uninitialized in Lambda)

	PR c++/52026
	* semantics.c (finish_id_expression): In a template, return
	the identifier for a constant variable.

From-SVN: r196081
parent 90680f3b
2013-02-15 Jason Merrill <jason@redhat.com>
PR c++/52026
* semantics.c (finish_id_expression): In a template, return
the identifier for a constant variable.
2013-02-14 Jason Merrill <jason@redhat.com>
PR c++/54922
......
......@@ -3015,7 +3015,14 @@ finish_id_expression (tree id_expression,
FIXME update for final resolution of core issue 696. */
if (decl_constant_var_p (decl))
{
if (processing_template_decl)
/* In a template, the constant value may not be in a usable
form, so look it up again at instantiation time. */
return id_expression;
else
return integral_constant_value (decl);
}
/* If we are in a lambda function, we can move out until we hit
1. the context,
......
// PR c++/52026
// { dg-options "-std=c++11 -O" }
// { dg-do run }
template<bool B>
int func() {
const int constVal1 = B ? 100 : -100;
const int constVal = constVal1;
return [] { return constVal; }();
}
int main() {
if (func<true>() != 100)
__builtin_abort ();
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment