https://gcc.gnu.org/bugzilla/show_bug.cgi?id=128801
Bug ID: 128801
Summary: Polymorphic assumed-rank coarray not rejected
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: ---
Testcase:
program prog
implicit none
type :: t
integer :: c
end type
type(t) :: a[2:5,9,*]
call sub(a)
contains
subroutine sub(x)
class(t), intent(in) :: x(..)[1:2,3:*]
end subroutine
end program prog
This causes an internal compiler error:
9 | subroutine sub(x)
| 1~~~~~~~~~~~~~
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
0x7f96375426af ???
./signal/../sysdeps/unix/sysv/linux/x86_64/libc_sigaction.c:0
0xc31b54 gfc_conv_array_bound
../../src/gcc/fortran/trans-types.cc:1432
0xc31b54 gfc_build_array_type
../../src/gcc/fortran/trans-types.cc:1633
0xc342d2 gfc_get_derived_type(gfc_symbol*, int)
../../src/gcc/fortran/trans-types.cc:3128
0xc34f05 gfc_typenode_for_spec(gfc_typespec*, int)
../../src/gcc/fortran/trans-types.cc:1389
0xc35321 gfc_sym_type(gfc_symbol*, bool)
../../src/gcc/fortran/trans-types.cc:2528
0xc32c3c gfc_get_function_type(gfc_symbol*, gfc_actual_arglist*, char const*)
../../src/gcc/fortran/trans-types.cc:3501
0xb8d761 build_function_decl
../../src/gcc/fortran/trans-decl.cc:2631
0xb97d6f gfc_create_function_decl(gfc_namespace*, bool)
../../src/gcc/fortran/trans-decl.cc:3475
0xb9f35e gfc_generate_contained_functions
../../src/gcc/fortran/trans-decl.cc:6585
0xb9f35e gfc_generate_function_code(gfc_namespace*)
../../src/gcc/fortran/trans-decl.cc:8425
0xaf5b3e translate_all_program_units
../../src/gcc/fortran/parse.cc:7751
0xaf5b3e gfc_parse_file()
../../src/gcc/fortran/parse.cc:8081
0xb5fa8f gfc_be_parse_file
../../src/gcc/fortran/f95-lang.cc:251
It should be rejected because of F2023:C839 (8.5.8.7):
> An assumed-rank entity shall be an associate name or a dummy data object that
> does not have the CODIMENSION or VALUE attribute.
If the type is non-polymorphic, the testcase is properly rejected:
9 | subroutine sub(x)
| 1
Error: Assumed-rank array at (1) may not have the VALUE or CODIMENSION
attribute
Referenced Bugs:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83700
[Bug 83700] [Meta-bug] Fortran Coarray issues