commit 4af96532b224029a20b192be2e7cedc60b9d12d0
Author: Jason Merrill <jason@redhat.com>
Date: Thu Apr 14 13:23:44 2016 -0400
PR c++/70543
* pt.c (value_dependent_expression_p) [VAR_DECL]: A type-dependent
initializer also makes the variable value-dependent.
@@ -22670,6 +22670,7 @@ value_dependent_expression_p (tree expression)
&& (TREE_CODE (DECL_INITIAL (expression)) == TREE_LIST
/* cp_finish_decl doesn't fold reference initializers. */
|| TREE_CODE (TREE_TYPE (expression)) == REFERENCE_TYPE
+ || type_dependent_expression_p (DECL_INITIAL (expression))
|| value_dependent_expression_p (DECL_INITIAL (expression))))
return true;
return false;
new file mode 100644
@@ -0,0 +1,17 @@
+// PR c++/70543
+// { dg-do compile { target c++11 } }
+
+template <typename>
+struct X
+{
+ template <unsigned int = 0>
+ static constexpr int
+ calc (void)
+ {
+ return 0;
+ }
+
+ static constexpr unsigned int value = calc ();
+
+ char foo[value];
+};