commit 25a2d664e6a3787cc68e3c41beb12330469ee4a5
Author: Jason Merrill <jason@redhat.com>
Date: Tue Oct 11 15:22:55 2011 -0400
PR c++/49216
* init.c (build_vec_init): Avoid crash on new int[1]{}.
@@ -3067,8 +3067,9 @@ build_vec_init (tree base, tree maxindex, tree init,
unsigned HOST_WIDE_INT idx;
tree field, elt;
/* Should we try to create a constant initializer? */
- bool try_const = (literal_type_p (inner_elt_type)
- || TYPE_HAS_CONSTEXPR_CTOR (inner_elt_type));
+ bool try_const = (TREE_CODE (atype) == ARRAY_TYPE
+ && (literal_type_p (inner_elt_type)
+ || TYPE_HAS_CONSTEXPR_CTOR (inner_elt_type)));
bool saw_non_const = false;
bool saw_const = false;
/* If we're initializing a static array, we want to do static
new file mode 100644
@@ -0,0 +1,6 @@
+// PR c++/49216
+// { dg-options -std=c++0x }
+
+int main() {
+ new int[1]{};
+}