https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100478
Bug ID: 100478
Summary: Type Pointer Segfaults
Product: gcc
Version: 11.1.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: fortran
Assignee: unassigned at gcc dot gnu.org
Reporter: poorasmith at protonmail dot com
Target Milestone: ---
The following program segfaults (11.1.0 and 9.3.0) with "option 2" (pointer
referencing itself) but works fine with "option 1" (direct reference). Both
options work fine with 7.5.0.
program fortranNull
implicit none
type myType
type(myType), pointer, dimension(:) :: someType => null()
end type myType
type(myType), target, dimension(1) :: typeTarget
type(myType), pointer, dimension(:) :: typePointer
character(len=1) :: arg
call get_command_argument(1, arg)
if (arg .eq. '1') then
write(*,*) 'Direct Assignment'
typePointer => typeTarget
typePointer => typeTarget(1)%someType
else if (arg .eq. '2') then
write(*,*) 'Referenced Assignment'
typePointer => typeTarget
typePointer => typePointer(1)%someType
else
write(*,*) 'expected either "1" or "2" command line argument'
end if
end program fortranNull