https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93365
--- Comment #4 from Steve Kargl <sgk at troutmask dot apl.washington.edu> ---
On Thu, Jan 23, 2020 at 03:37:04PM +0000, markeggleston at gcc dot gnu.org
wrote:
>
> If the parameter attribute is removed or a non zero sized array is used, the
> ICE does not occur.
>
> The ICE occurs in gfc_match_varspec (primary.c) a temporary gfc_ref structure
> has been created and has the type REF_INQUIRY. If the primary expression has
> been passed in is EXPR_CONSTANT the check is done. When the ICE occurs the
> type
> is EXPR_STRUCTURE, so the value of the REF_INQUIRY taken from u.i is used for
> the inquiry type instead of being 2 (INQUIRY_KIND) it is random e.g.73176720.
>
Not quite, right. If you have
complex, parameter :: a(1) = 0
integer b
data b/a%kind%
then at line 2337 in primary.c
gfc_simplify_expr (primary, 0);
collapses primary to an EXPR_CONSTANT, and then things seem to work.
If you have
complex, parameter :: a(0) = 0
integer b
data b/a%kind%
then "gfc_simplify_expr (primary, 0)" does not collapse primary
to EXPR_CONSTANT as it seems gfc_simplify_expr does not handle
zero size arrays (as there is nothing to simplify!). gfortran
then enters the switch statement and get to lines 2384-2385
primary->ts.type = BT_INTEGER;
primary->ts.kind = gfc_default_integer_kind;
This just resets a part of primary, but it does not fix up
it up correctly. Likely, need to check for zero size
arrays do extra work.