http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51639
Bug #: 51639
Summary: Nested type pointer null initialisation fails
Classification: Unclassified
Product: gcc
Version: 4.6.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: fortran
AssignedTo: [email protected]
ReportedBy: [email protected]
The following code appears to produce a regression in 4.6:
program main
implicit none
type type1
integer, dimension(:), allocatable :: member
end type type1
type type2
type(type1), pointer :: t1ptr=>null()
end type type2
call test
contains
subroutine test
type(type2) :: t2
print *, "associated(t2%t1ptr) = ", associated(t2%t1ptr)
end subroutine test
end program
Produces the output
associated(t2%t1ptr) = T
but should produce the output
associated(t2%t1ptr) = F
Further valgrind shows that access is to an uninitialised pointer.
The code works as expected under 4.4.6 and 4.5.4.
To provoke the error it seems that the associated() check must occur within a
subroutine, and that type1 must have an allocatable component.
Thanks,
Jonathan.