This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug fortran/51435] New: Bad association status after null() of derived type component
- From: "darmar.xxl at gmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Tue, 06 Dec 2011 09:28:41 +0000
- Subject: [Bug fortran/51435] New: Bad association status after null() of derived type component
- Auto-submitted: auto-generated
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51435
Bug #: 51435
Summary: Bad association status after null() of derived type
component
Classification: Unclassified
Product: gcc
Version: 4.6.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: fortran
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: darmar.xxl@gmail.com
Created attachment 26002
--> http://gcc.gnu.org/bugzilla/attachment.cgi?id=26002
test code
Here is the code:
!---------------
module arr_m
type arr_t
real(8), dimension(:), allocatable :: rsk
! if allocatable changed to pointer, all is OK
end type
end module arr_m
!*********************
module list_m
use arr_m
implicit none
type my_list
type(arr_t), pointer :: head => null()
!!!integer, pointer :: tail => null() !if this is uncommented, all
is OK.
end type my_list
end module list_m
!***********************
module worker_mod
use list_m
implicit none
type data_all_t
type(my_list) :: my_data
end type data_all_t
contains
subroutine do_job()
type(data_all_t) :: dum
if (associated(dum%my_data%head)) then
print *, 'do_job my_data%head is associated'
!
! gfortran goes here.
! WRONG. head was nullified.
!
else
print *, 'do_job my_data%head is NOT associated' ! OK
end if
end subroutine
end module
!***************
program hello
use worker_mod
implicit none
call do_job()
end program
!***************
gfortran reports that dum%my_data%head is associated in the sub "do_job", while
"head" component was nullified using null() in the variable declaration line.
I tested this with gfortran 4.6 and 4.7 on Linux and Windows (produces wrong
results). Version 4.5 outputs correct result. (ifort is OK).