https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114021
Bug ID: 114021
Summary: ICE with allocation of scalar pointer entity where
SOURCE=f() with f() returning a pointer
Product: gcc
Version: 14.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: fortran
Assignee: unassigned at gcc dot gnu.org
Reporter: kargl at gcc dot gnu.org
Target Milestone: ---
Note sure if this is legal Fortran, but it leads to an ICE.
Reduced testcase from Fujitsu testsuite.
!
! https://github.com/fujitsu/compiler-test-suite
! Reduced from 0077/0077_0005.f90
!
module m1
type y
integer, allocatable:: x1(:)
end type
type(y), target :: w
integer :: c = 0
contains
function f()
type(y), pointer :: f
f => w
c = c + 1
end function
end
subroutine s2
use m1
! type(y), allocate :: x ! This ICEs as well
type(y), pointer :: x
allocate(x, source = f())
end
use m1
call s2
if (c /= 1) stop
end
% gfcx -o z 0077/0077_0005.f90
0077/0077_0005.f90:21:28:
21 | allocate(x, source = f())
| 1
internal compiler error: Segmentation fault
0x109b292 crash_signal
../../gccx/gcc/toplev.cc:317
0x2470c137f handle_signal
/usr/src/lib/libthr/thread/thr_sig.c:301
0x2470c09b7 thr_sighandler
/usr/src/lib/libthr/thread/thr_sig.c:244
0xacea7d tree_check(tree_node*, char const*, int, char const*, tree_code)
../../gccx/gcc/tree.h:3611
0xacea7d gfc_trans_allocate(gfc_code*, gfc_omp_namelist*)
../../gccx/gcc/fortran/trans-stmt.cc:6672