Comments
Patch
@@ -422,7 +422,9 @@ build_value_init_noctor (tree type, tsubst_flags_t complain)
as we don't know the size of the array yet. */
if (max_index == error_mark_node)
{
- error ("cannot value-initialize array of unknown bound %qT", type);
+ if (complain & tf_error)
+ error ("cannot value-initialize array of unknown bound %qT",
+ type);
return error_mark_node;
}
gcc_assert (TREE_CODE (max_index) == INTEGER_CST);
new file mode 100644
@@ -0,0 +1,12 @@
+// PR c++/48531
+// { dg-options -std=c++0x }
+
+template<class T,
+ class = decltype(T())
+>
+char f(int);
+
+template<class>
+char (&f(...))[2];
+
+static_assert(sizeof(f<int[]>(0)) != 1, "Error");
Here's the one where we just need to check complain before giving an error. Tested x86_64-pc-linux-gnu, applying to trunk. commit a9fa1134b357ad03ac5279c926d67af75728062d Author: Jason Merrill <jason@redhat.com> Date: Wed Apr 13 18:17:17 2011 -0400 PR c++/48531 * init.c (build_value_init_noctor): Check complain consistently.