Commit a8e6c82a by Mark Mitchell Committed by Mark Mitchell

re PR c++/13574 (array default initializer in class lets gcc consume all memory and die)

	PR c++/13574
	* decl.c (compute_array_index_type): Fix grammar in comment.
	* init.c (build_zero_init): Handle zero-sized arrays correctly.

	PR c++/13574
	* g++.dg/ext/array1.C: New test.

From-SVN: r75991
parent 965514bd
......@@ -4,6 +4,10 @@
2004-01-16 Mark Mitchell <mark@codesourcery.com>
PR c++/13574
* decl.c (compute_array_index_type): Fix grammar in comment.
* init.c (build_zero_init): Handle zero-sized arrays correctly.
PR c++/13178
* call.c (name_as_c_string): Print conversion operator names
correctly.
......
......@@ -6079,9 +6079,8 @@ compute_array_index_type (tree name, tree size)
error ("size of array is negative");
size = integer_one_node;
}
/* Except that an extension we allow zero-sized arrays. We
always allow them in system headers because glibc uses
them. */
/* As an extension we allow zero-sized arrays. We always allow
them in system headers because glibc uses them. */
else if (integer_zerop (size) && pedantic && !in_system_header)
{
if (name)
......
......@@ -228,14 +228,17 @@ build_zero_init (tree type, tree nelts, bool static_storage_p)
max_index = nelts ? nelts : array_type_nelts (type);
my_friendly_assert (TREE_CODE (max_index) == INTEGER_CST, 20030618);
for (index = size_zero_node;
!tree_int_cst_lt (max_index, index);
index = size_binop (PLUS_EXPR, index, size_one_node))
inits = tree_cons (index,
build_zero_init (TREE_TYPE (type),
/*nelts=*/NULL_TREE,
static_storage_p),
inits);
/* A zero-sized array, which is accepted as an extension, will
have an upper bound of -1. */
if (!tree_int_cst_equal (max_index, integer_minus_one_node))
for (index = size_zero_node;
!tree_int_cst_lt (max_index, index);
index = size_binop (PLUS_EXPR, index, size_one_node))
inits = tree_cons (index,
build_zero_init (TREE_TYPE (type),
/*nelts=*/NULL_TREE,
static_storage_p),
inits);
CONSTRUCTOR_ELTS (init) = nreverse (inits);
}
else if (TREE_CODE (type) == REFERENCE_TYPE)
......
2004-01-16 Mark Mitchell <mark@codesourcery.com>
PR c++/13574
* g++.dg/ext/array1.C: New test.
PR c++/13178
* g++.dg/conversion/op1.C: New test.
......
// PR c++/13574
// { dg-options "" }
class A {
public:
A() : argc(0), argv() { };
private:
int argc;
char* argv[];
};
int main() {
A y;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment