The following was reported by John McFarland: PROGRAM prog
ABSTRACT INTERFACE SUBROUTINE sub_template(i,j,o) INTEGER, INTENT(in) :: i INTEGER, INTENT(in), OPTIONAL :: j, o END SUBROUTINE sub_template END INTERFACE TYPE container PROCEDURE(sub_template), POINTER, NOPASS :: s END TYPE container PROCEDURE(sub_template), POINTER :: s TYPE (container) :: c c%s => sub s => sub CALL callf(s) CALL callfc(c) CONTAINS SUBROUTINE callfc(c) TYPE (container) :: c PRINT*, 'Calling with ppc' CALL c%s(1,o=3) END SUBROUTINE callfc SUBROUTINE callf(f) PROCEDURE(sub_template), OPTIONAL, POINTER :: f PRINT*, 'Calling pp argument' CALL f(1,o=5) END SUBROUTINE callf SUBROUTINE sub(i,arg2,arg3) INTEGER, INTENT(in) :: i INTEGER, INTENT(in), OPTIONAL :: arg2, arg3 PRINT*, 'i:', i PRINT*, 'Present:', PRESENT(arg2), PRESENT(arg3) IF (PRESENT(arg2)) PRINT*, 'arg2:', arg2 IF (PRESENT(arg3)) PRINT*, 'arg3:', arg3 END SUBROUTINE sub END PROGRAM prog This program compiles fine, but produces the output: Calling pp argument i: 1 Present: F T arg3: 5 Calling with ppc i: 1 Present: T T arg2: 3 arg3: -443987883 This means that there is a problem with calling PPCs with optional arguments. -- Summary: [F03] Procedure Pointer Components with OPTIONAL arguments 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=40427