Silverfrost Forums

Welcome to our forums

Associated() failing with 64 bit compiler

24 Apr 2018 7:47 #21945

In the following code the associated() intrinsic incorrectly returns .TRUE. causing a run-time error when the deallocate statement is executed.

Since ⇒ null() initialisation is used the initial status of array subobject a is .not. associated. The code complies with the Standard.

This error occurs with the 64 bit compiler (irrespective of options used). The code works properly with the 32 bit compiler.

module global_array

   type wrap_t
      real, pointer :: a(:) => null()
   end type wrap_t
   
   type (wrap_t) :: wrapper(4)
   
contains

   subroutine tidy_up()
   
      integer :: i
      
      do i=1, 4
         if (associated(wrapper(i)%a)) then
            deallocate(wrapper(i)%a)
         end if
      end do
   
   end subroutine tidy_up
   
end module global_array

program test

   use global_array
   
   ! wrapper%a is not associated
   
   ! You get an error when tidy_up is called because associated function returns true
   ! Error is then generated at the deallocate statement
   call tidy_up()

end program test

This is the last of the issues with 8.3 I am aware of.

24 Apr 2018 8:50 #21947

Thanks. I have made a note that this needs fixing.

25 Apr 2018 10:38 #21971

For me this only fails with /64 /UNDEF where the expected zero for the NULL is being incorrectly over-written by the 'undefined' state.

So the temporary work-around is to avoid /UNDEF in this context.

1 May 2018 8:43 #22054

This has now been fixed for the next release of FTN95.

Please login to reply.