https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103283
anlauf at gcc dot gnu.org changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |wrong-code
--- Comment #4 from anlauf at gcc dot gnu.org ---
(In reply to anlauf from comment #3)
> integer, parameter :: k(*) = x(1)%a
>
> This fails with:
>
> pr103283-z1.f90:6:28:
>
> 6 | integer, parameter :: k(*) = x(1)%a
> | 1
> Error: Cannot initialize implied-shape array at (1) with scalar
Doing some debugging, we seem to lose the shape when simplifying the r.h.s.
near the end of expr.c::simplify_parameter_variable:
/* Do not copy subobject refs for constant. */
if (e->expr_type != EXPR_CONSTANT && p->ref != NULL)
e->ref = gfc_copy_ref (p->ref);
t = gfc_simplify_expr (e, type);
Initially the ref looks fine, but it might be evaluated improperly.
We end up with a scalar instead of a rank-1 array.