Incorrect(?) warning

Andrew Benson abenson@obs.carnegiescience.edu
Thu Jan 3 00:06:00 GMT 2013


The following:

module eventMod
  type, public :: event
     private
    procedure(eventTask ), pointer, public :: task
 end type event
  abstract interface
     logical function eventTask(self)
       import event
       class(event), intent(in) :: self
     end function eventTask
  end interface
end module eventMod
program test
  use eventMod
  implicit none
  logical :: r
  type(event), pointer :: myEvent
  allocate(myEvent)
  r=myEvent%task()
end program test

causes the following warning when compiled (with gfortran 4.8.0):

$ gfortran -v
Using built-in specs.
COLLECT_GCC=gfortran
COLLECT_LTO_WRAPPER=/home/abenson/Galacticus/Tools/libexec/gcc/x86_64-unknown-
linux-gnu/4.8.0/lto-wrapper
Target: x86_64-unknown-linux-gnu
Configured with: ../gcc-trunk/configure --
prefix=/home/abenson/Galacticus/Tools --enable-languages=c,c++,fortran --
disable-multilib --with-gmp=/home/abenson/Galacticus/Tools
Thread model: posix
gcc version 4.8.0 20121219 (experimental) (GCC) 

$ gfortran -o warn.exe warn.F90 -Wall
warn.F90:19.4:

  r=myEvent%task()
    1
Warning: POINTER valued function appears on right-hand side of assignment at 
(1)

As far as I can tell, the code runs correctly despite this warning.

I'm wondering if the warning is spurious. The "task" function is not pointer-
valued (it returns a logical).

Or maybe I'm misunderstanding the warning?

Thanks,
Andrew.

-- 

* Andrew Benson: http://users.obs.carnegiescience.edu/abenson/contact.html

* Galacticus: http://sites.google.com/site/galacticusmodel



More information about the Fortran mailing list