mysterious associated behavior compiled with gfortran

前端 未结 1 1231
天命终不由人
天命终不由人 2021-01-25 06:38

I have the following short fortran code.

  !==============================================
  MODULE PREC
  INTEGER, PARAMETER :: q=8
  END MODULE PREC

  !=====         


        
1条回答
  •  伪装坚强ぢ
    2021-01-25 07:43

    No, the status of your pointer is undefined. You are not allowed to inquire it using associated() because it can result in anything.

    What you should always do is to use default initialization of all pointer components and initialize them to null().

    TYPE spec
        COMPLEX(q), POINTER :: HMAT(:,:) => null()
    END TYPE
    

    After that you are guaranteed to get the expected result false.

    0 讨论(0)
提交回复
热议问题