maybe_constant_value doesn't deal well with void expressions, and we shouldn't expect it to.

Tested x86_64-pc-linux-gnu, applying to trunk and 4.8.
commit 0d1fe0783012b1e43b630f526f90e3a9cd6be434
Author: Jason Merrill <ja...@redhat.com>
Date:   Mon Jan 27 10:01:30 2014 -0500

    	PR c++/59097
    	* decl.c (compute_array_index_type): Don't call
    	maybe_constant_value for a non-integral expression.

diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index 38f2de0..7ebb05d 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -8262,7 +8262,9 @@ compute_array_index_type (tree name, tree size, tsubst_flags_t complain)
 	      abi_1_itype = error_mark_node;
 	    }
 
-	  size = maybe_constant_value (size);
+	  if (INTEGRAL_OR_UNSCOPED_ENUMERATION_TYPE_P (type))
+	    size = maybe_constant_value (size);
+
 	  if (!TREE_CONSTANT (size))
 	    size = osize;
 	}
diff --git a/gcc/testsuite/g++.dg/ext/stmtexpr15.C b/gcc/testsuite/g++.dg/ext/stmtexpr15.C
new file mode 100644
index 0000000..83a831c
--- /dev/null
+++ b/gcc/testsuite/g++.dg/ext/stmtexpr15.C
@@ -0,0 +1,7 @@
+// PR c++/59097
+// { dg-options "" }
+
+void foo()
+{
+  int x[({ return; })];		// { dg-error "non-integral" }
+}

Reply via email to