https://gcc.gnu.org/bugzilla/show_bug.cgi?id=127724
Bug ID: 127724
Summary: ICE on coarray deallocation
Product: gcc
Version: 17.0
Status: UNCONFIRMED
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
use, intrinsic :: iso_fortran_env, only: team_type
implicit none
type(team_type) :: team
integer, allocatable :: a[:]
integer :: team_id
if (num_images() == 1) stop
team_id = 1 + mod(this_image(), 2)
form team (team_id, team)
change team (team)
if (team_id == 1) then
allocate(a[*])
deallocate(a)
end if
end team
end program
Compiling with -fcoarray=single produces:
> f951: internal compiler error: Segmentation fault
> 0x2979e1f internal_error(char const*, ...)
> ../../src/gcc/diagnostic-global-context.cc:787
> 0x12b91cf crash_signal
> ../../src/gcc/toplev.cc:325
> 0x7f39c9e846af ???
> ./signal/../sysdeps/unix/sysv/linux/x86_64/libc_sigaction.c:0
> 0xb2f998 deallocate_allocated_coarrays(vec<gfc_expr*, va_heap, vl_ptr>*)
> ../../src/gcc/fortran/st.cc:454
> 0xae3400 parse_change_team
> ../../src/gcc/fortran/parse.cc:5683
> 0xae3400 parse_executable
> ../../src/gcc/fortran/parse.cc:6864
> 0xae53a9 parse_progunit
> ../../src/gcc/fortran/parse.cc:7275
> 0xae690d gfc_parse_file()
> ../../src/gcc/fortran/parse.cc:7843
> 0xb4f6af gfc_be_parse_file
> ../../src/gcc/fortran/f95-lang.cc:251
st.cc contains:
449 /* Insert the deallocation code before the END TEAM statement.
*/
450 last_stmt = gfc_current_ns->code;
451 while (last_stmt)
452 {
453 last_stmt = last_stmt->next;
454 if (last_stmt->next->op == EXEC_END_TEAM || !last_stmt->next)
455 {
In the "if", last_stmt->next is checked after it is accessed. Oops...
I guess the first part of it should be last_stmt->op == EXEC_END_TEAM.