[Patch, Fortran] PR56650/36437 - Add compile-time simplification for (c_)sizeof, storage_size

Thomas Koenig tkoenig@netcologne.de
Wed Mar 27 09:48:00 GMT 2013


Hi Tobias,

I think you need to deallocate array_size in gfc_simplify_sizeof
unconditionally.

> +  if (x->rank && x->expr_type != EXPR_ARRAY
> +      && gfc_array_size (x, &array_size) == FAILURE)
> +    return NULL;

Here, it is allocated on success of gfc_array_size.

[...]

And here, it is freed only if expr_type != EXPR_ARRAY.

> +  if (x->rank && x->expr_type != EXPR_ARRAY)
> +    {
> +      mpz_mul (result->value.integer, result->value.integer, array_size);
> +      mpz_clear (array_size);
> +    }

Otherwise, the patch looks OK for me.

	Thomas



More information about the Gcc-patches mailing list