[Bug fortran/41733] Proc-pointer conformance checks: Elemental-proc-ptr => non-elemental-proc
burnus at gcc dot gnu dot org
gcc-bugzilla@gcc.gnu.org
Fri Oct 16 20:35:00 GMT 2009
------- Comment #1 from burnus at gcc dot gnu dot org 2009-10-16 20:35 -------
The first example,
procedure(fun), pointer :: f
f => my_dcos
write(*,*) f(x)
looks fine to me. "fun" is elemental - and my_dcos is also elemental.
The second example is wrong: "fun" is elemental, but "my_dcos" is not thus
f => my_dcos
is invalid per F2003, 7.4.2.2 Procedure pointer assignment:
"If proc-pointer-object has an explicit interface, its characteristics shall
be
the same as proc-target except that proc-target may be pure even if
proc-pointer-object is not pure and proc-target may be an elemental intrinsic
procedure even if proc-pointer-object is not elemental."
The third example looks OK again - actually, it is the same as the first,
except that one uses an intrinsic elemental procedure (dcos).
Test case for the second example:
module funcs
implicit none
integer, parameter :: dp = kind(1.0d0)
abstract interface
elemental function fun(x)
import
implicit none
real(dp), intent(in) :: x
real(dp) fun
end function fun
end interface
contains
function my_dcos(x)
integer, parameter :: dp = kind(1.0d0)
real(dp), intent(in) :: x
real(dp) :: my_dcos
my_dcos = cos(x)
end function
end module funcs
program start
use funcs
implicit none
procedure(fun), pointer :: f
real(dp) x(3)
x = [1,2,3]
f => my_dcos
write(*,*) f(x)
end program start
--
burnus at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Summary|Proc-pointer conformance |Proc-pointer conformance
|checks |checks: Elemental-proc-ptr
| |=> non-elemental-proc
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=41733
More information about the Gcc-bugs
mailing list