[Bug fortran/124598] (PDT) - ICE instantiating nested PDTs
kargl at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Mon Mar 23 21:39:46 GMT 2026
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=124598
--- Comment #3 from Steve Kargl <kargl at gcc dot gnu.org> ---
(In reply to Steve Kargl from comment #2)
> (In reply to anlauf from comment #1)
> > I do not get an ICE with 16-trunk; the testcase gets (correctly) rejected:
> >
> > pr124958.f90:18:14:
> >
> > 18 | type(t_baz(n)) :: baz ! <- REMOVE THIS LINE AND THIS PROGRAM
> > COMPILES
> > | 1
> > Error: The type parameter expression at (1) must be of INTEGER type and not
> > UNKNOWN
> >
> >
> > Intel also rejects it:
> >
> > pr124958.f90(18): error #6219: This variable, used in a specification
> > expression, must be a dummy argument, a COMMON block object, or an object
> > accessible through host or use association. [N]
> > type(t_baz(n)) :: baz ! <- REMOVE THIS LINE AND THIS PROGRAM COMPILES
> > --------------^
> > pr124958.f90(18): error #6591: An automatic object is invalid in a main
> > program. [BAZ]
> > type(t_baz(n)) :: baz ! <- REMOVE THIS LINE AND THIS PROGRAM COMPILES
> > ---------------------^
> > compilation aborted for pr124958.f90 (code 1)
>
> 'n' is a type-param-name in 'type(t_baz(n)) :: baz'. OP's code is likely
> invalid because 'n' does not appear in an specification expression.
>
> However, if one changes the code to
>
> type(t_baz) :: baz ! <- REMOVE THIS LINE AND THIS PROGRAM COMPILES
>
> or
>
> type(t_baz(n=10)) :: baz ! <- REMOVE THIS LINE AND THIS PROGRAM COMPILES
>
> you get an ICE. In the former case, one uses the initialization value of '1'
>
> type t_baz(n)
> integer, len :: n = 1
> type(t_bar(n)) :: bar(n)
> end type t_baz
>
> and in the latter one has 'n=10'. If I expand what I think is intended
> with 'n=10', one has 'baz(1:10)%foo(1:10)%c' where I'm showing the array
> section notation.
Small correction: baz%bar(1:10)%foo(1:10)%c
More information about the Gcc-bugs
mailing list