Incorrect(?) warning

Janus Weil janus@gcc.gnu.org
Thu Jan 3 06:36:00 GMT 2013


Hi Andrew,

> 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).

Yes, since the procedure is clearly not pointer-valued, the warning is
bogus (seems like gfortran is irritated by the fact that the base
object is pointer-valued). I can reproduce this behavior with 4.6, 4.7
and trunk. Can you file a PR?

Thanks,
Janus



More information about the Fortran mailing list