Comments
Patch
@@ -18085,10 +18085,10 @@ value_dependent_expression_p (tree expression)
return value_dependent_expression_p (DECL_INITIAL (expression));
case VAR_DECL:
- /* A constant with integral or enumeration type and is initialized
+ /* A constant with literal type and is initialized
with an expression that is value-dependent. */
if (DECL_INITIAL (expression)
- && INTEGRAL_OR_ENUMERATION_TYPE_P (TREE_TYPE (expression))
+ && decl_constant_var_p (expression)
&& value_dependent_expression_p (DECL_INITIAL (expression)))
return true;
return false;
new file mode 100644
@@ -0,0 +1,7 @@
+// PR c++/48265
+// { dg-options -std=c++0x }
+
+template < int > struct S
+{
+ S () { const int i = i; i; };
+};
We were infinitely recursing in value_dependent_expression_p. As it happens, we're already doing the heavy lifting for determining whether or not a potentially constant variable has a constant initializer, so we can just use decl_constant_var_p here. Tested x86_64-pc-linux-gnu, applied to trunk and 4.6. commit 5f044d8e087ad43de99c062fea1ed58398f6f977 Author: Jason Merrill <jason@redhat.com> Date: Tue Mar 29 15:05:27 2011 -0400 PR c++/48265 * pt.c (value_dependent_expression_p) [VAR_DECL]: Make sure the variable is constant before looking at its initializer.