https://gcc.gnu.org/bugzilla/show_bug.cgi?id=128803
Bug ID: 128803
Summary: Error recovery ICE with assumed-rank coarray
Product: gcc
Version: 17.0
Status: UNCONFIRMED
Keywords: error-recovery, ice-on-invalid-code
Severity: normal
Priority: P3
Component: fortran
Assignee: unassigned at gcc dot gnu.org
Reporter: mikael at gcc dot gnu.org
Target Milestone: ---
Testcase:
program prog
implicit none
integer :: a[1:3,4,*]
call sub(a)
contains
subroutine sub(x)
integer, intent(in) :: x(..)[2:5,9:*]
print *, size(x)
end subroutine
end program prog
The compiler (correctly) rejects this and then aborts with an internal compiler
error:
6 | subroutine sub(x)
| 1
Error: Assumed-rank array at (1) may not have the VALUE or CODIMENSION
attribute
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
0x7eff834226af ???
./signal/../sysdeps/unix/sysv/linux/x86_64/libc_sigaction.c:0
0xa6935a free_expr0
../../src/gcc/fortran/expr.cc:491
0xa692f4 gfc_free_expr(gfc_expr*)
../../src/gcc/fortran/expr.cc:586
0xa692f4 gfc_free_expr(gfc_expr*)
../../src/gcc/fortran/expr.cc:582
0xa692f4 gfc_free_ref_list(gfc_ref*)
../../src/gcc/fortran/expr.cc:664
0xa693fa free_expr0
../../src/gcc/fortran/expr.cc:571
0xa69537 gfc_free_expr(gfc_expr*)
../../src/gcc/fortran/expr.cc:586
0xa69537 gfc_free_expr(gfc_expr*)
../../src/gcc/fortran/expr.cc:582
0xa69537 gfc_free_actual_arglist(gfc_actual_arglist*)
../../src/gcc/fortran/expr.cc:602
0xa69537 free_expr0
../../src/gcc/fortran/expr.cc:541
0xa696b2 gfc_free_expr(gfc_expr*)
../../src/gcc/fortran/expr.cc:586
0xa696b2 gfc_free_expr(gfc_expr*)
../../src/gcc/fortran/expr.cc:582
0xb3f519 gfc_free_statement(gfc_code*)
../../src/gcc/fortran/st.cc:86
0xb3f9df gfc_free_statements(gfc_code*)
../../src/gcc/fortran/st.cc:339
0xb3f9df gfc_free_statements(gfc_code*)
../../src/gcc/fortran/st.cc:338
0xb4c50f gfc_free_namespace(gfc_namespace*&)
../../src/gcc/fortran/symbol.cc:4443
0xb4c844 gfc_free_namespace(gfc_namespace*&)
../../src/gcc/fortran/symbol.cc:4503
0xb4d8bf gfc_symbol_done_2()
../../src/gcc/fortran/symbol.cc:4524
The intrinsic used (SIZE here) is not important, but having the invalid
assumed-rank coarray as argument is crucial.
This is similar to PR128802, but the stacktrace is different.