http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58099

janus at gcc dot gnu.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
                 CC|                            |janus at gcc dot gnu.org
         Resolution|---                         |INVALID
            Summary|over-zealous Error pointer  |[F03] over-zealous
                   |error checking in gfortran  |procedure pointer error
                   |4.8                         |checking in gfortran 4.8

--- Comment #3 from janus at gcc dot gnu.org ---
(In reply to Daniel Price from comment #0)
> 
> ../src/kernels.f90:77.13:
> 
>     wfunc => w_wendlandc6
>              1
> Error: Interface mismatch in procedure pointer assignment at (1): Mismatch
> in PURE attribute
> 
> While I can provide a workaround for this by removing the pure attribute, I
> think this is either a bug or a feature that I don't understand, since it
> must be possible to point to pure procedures with a procedure pointer.

This is clearly a feature, not a bug. And yes, it is possible to point to a
pure procedure with a procedure pointer. You just have to make sure that the
proc-ptr interface is declared to be pure, too.

The reduced test case below shows two examples of how this can be accomplished.


  implicit none

  interface
    pure real function ifc(q)
      real, intent(in) :: q
    end function
  end interface

  procedure(real),    pointer :: wfunc1
  procedure(w_cubic), pointer :: wfunc2
  procedure(ifc),     pointer :: wfunc3

  wfunc1 => w_cubic   ! invalid
  wfunc2 => w_cubic   ! valid
  wfunc3 => w_cubic   ! valid

contains

  pure real function w_cubic(q2)
    real, intent(in) :: q2
    w_cubic = 0.
  end function

end

Since this is a non-bug, I'm closing it as invalid.

Reply via email to