https://gcc.gnu.org/bugzilla/show_bug.cgi?id=124598
Steve Kargl <kargl at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |kargl at gcc dot gnu.org
--- Comment #2 from Steve Kargl <kargl at gcc dot gnu.org> ---
(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.