[Bug fortran/41139] New: [4.5 Regression] a procedure pointer call as actual argument
janus at gcc dot gnu dot org
gcc-bugzilla@gcc.gnu.org
Fri Aug 21 13:22:00 GMT 2009
PROGRAM test
PROCEDURE(add), POINTER :: f
! Passing the function works
print *,greater(4.,add(1.,2.))
! Passing the procedure pointer fails
f => add
print *,greater(4.,f(1.,2.))
CONTAINS
REAL FUNCTION add(x,y)
REAL, INTENT(in) :: x,y
print *,"add:",x,y
add = x+y
END FUNCTION add
LOGICAL FUNCTION greater(x,y)
REAL, INTENT(in) :: x, y
greater = (x > y)
END FUNCTION greater
END PROGRAM test
This code produces the following output:
add: 1.0000000 2.0000000
T
add: 1.0000000 2.0000000
Segmentation fault
Looking at the ouput of -fdump-tree-original, one can see a difference between
the two calls to 'greater':
D.1563 = add (&C.1561, &C.1562);
D.1564 = greater (&C.1560, &D.1563);
D.1570 = greater (&C.1567, f (&C.1568, &C.1569));
I.e. in the first case a temporary variable is inserted for the result of
'add', while in the second case this is not the case (which is the reason for
the segfault).
gfortran 4.4 behaves correctly.
Reported by Barron Bichon.
--
Summary: [4.5 Regression] a procedure pointer call as actual
argument
Product: gcc
Version: 4.5.0
Status: UNCONFIRMED
Keywords: wrong-code
Severity: normal
Priority: P3
Component: fortran
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: janus at gcc dot gnu dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=41139
More information about the Gcc-bugs
mailing list