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