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: unassig...@gcc.gnu.org ReportedBy: darmar....@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).