[Bug fortran/97920] New: [FINAL] -O2 segment fault due to extend derive type's member being partially allocated
xin.liu@compiler-dev.com
gcc-bugzilla@gcc.gnu.org
Fri Nov 20 02:08:34 GMT 2020
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97920
Bug ID: 97920
Summary: [FINAL] -O2 segment fault due to extend derive type's
member being partially allocated
Product: gcc
Version: unknown
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: fortran
Assignee: unassigned at gcc dot gnu.org
Reporter: xin.liu@compiler-dev.com
Target Milestone: ---
Consider the following Fortran testcase:
module m
type t1
real, dimension(:), pointer :: a
contains
final :: t1f
end type
type, extends(t1) :: t2
real, dimension(:), pointer :: b
contains
final :: t2f
end type
contains
subroutine t1f(x)
type(t1) :: x
if (associated(x%a)) deallocate(x%a)
end subroutine
subroutine t2f(x)
type(t2) :: x
if (associated(x%b)) deallocate(x%b)
end subroutine
end module
subroutine test
use m
implicit none
type(t1) :: a
type(t2) :: b
allocate(b%a(3))
! allocate(b%b(3))
end subroutine
program p
use m
call test()
end program
Compiled with gfortran 10.1.0 in -O2, the testcase prints:
Program received signal SIGSEGV: Segmentation fault - invalid memory reference.
If add a statement as 'allocate(b%b(3))', it will pass with no segment fault.I
guess this segment fault maybe due to extend derive type's member being
partially allocated.
More information about the Gcc-bugs
mailing list