{
gfc_expr *result = 0L;
int i, j, dim, ncopies;
+ mpz_t size;
if ((!gfc_is_constant_expr (source)
&& !is_constant_array_expr (source))
gfc_extract_int (ncopies_expr, &ncopies);
ncopies = MAX (ncopies, 0);
+ /* Do not allow the array size to exceed the limit for an array
+ constructor. */
+ gfc_array_size (source, &size);
+ if (mpz_get_si (size)*ncopies > gfc_option.flag_max_array_constructor)
+ return NULL;
+
if (source->expr_type == EXPR_CONSTANT)
{
gcc_assert (dim == 0);