https://gcc.gnu.org/bugzilla/show_bug.cgi?id=128812
Bug ID: 128812
Summary: ICE with allocatiable coarray argument association
when types don't match
Product: gcc
Version: 17.0
Status: UNCONFIRMED
Keywords: ice-on-invalid-code
Severity: normal
Priority: P3
Component: fortran
Assignee: unassigned at gcc dot gnu.org
Reporter: mikael at gcc dot gnu.org
Blocks: 83700
Target Milestone: ---
The testcase is a variant of that of PR128806:
program prog
implicit none
integer, parameter :: n = 5
type :: t
integer :: c
end type
class(t), allocatable :: a[:]
integer :: i
allocate(a[5:*])
a%c = 7
call sub2(a)
contains
subroutine sub2(x)
type(t), allocatable, intent(in) :: x[:,:]
end subroutine
end program prog
It causes a crash of the compiler:
f951: internal compiler error: Segmentation fault
0x293426f internal_error(char const*, ...)
../../src/gcc/diagnostic-global-context.cc:787
0x12df4cf crash_signal
../../src/gcc/toplev.cc:325
0x7f172796f6af ???
./signal/../sysdeps/unix/sysv/linux/x86_64/libc_sigaction.c:0
0xa7bde7 compare_parameter
../../src/gcc/fortran/interface.cc:2778
0xa7cdf7 gfc_compare_actual_formal(gfc_actual_arglist**, gfc_formal_arglist*,
int, int, bool, locus*)
../../src/gcc/fortran/interface.cc:3583
0xa7f960 gfc_procedure_use(gfc_symbol*, gfc_actual_arglist**, locus*)
../../src/gcc/fortran/interface.cc:4739
0xb1e966 resolve_unknown_s
../../src/gcc/fortran/resolve.cc:3983
0xb1e966 resolve_call
../../src/gcc/fortran/resolve.cc:4330
0xb0b2ae gfc_resolve_code(gfc_code*, gfc_namespace*)
../../src/gcc/fortran/resolve.cc:15075
0xb0dc1b resolve_codes
../../src/gcc/fortran/resolve.cc:21228
0xb0dcf9 gfc_resolve(gfc_namespace*, gfc_association_list*)
../../src/gcc/fortran/resolve.cc:21512
0xaf54e2 resolve_all_program_units
../../src/gcc/fortran/parse.cc:7681
0xaf54e2 gfc_parse_file()
../../src/gcc/fortran/parse.cc:7948
0xb5fa8f gfc_be_parse_file
../../src/gcc/fortran/f95-lang.cc:251
The test is invalid because of F2023 (15.5.2.6: Allocatable and pointer dummy
variables):
> The actual argument shall be polymorphic if and only if the associated dummy
> argument is polymorphic, and either both the actual and dummy arguments shall
> be unlimited polymorphic, or the declared type of the actual argument shall be
> the same as the declared type of the dummy argument.
Referenced Bugs:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83700
[Bug 83700] [Meta-bug] Fortran Coarray issues