public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/40427]  New: [F03] Procedure Pointer Components with OPTIONAL arguments
@ 2009-06-12 13:14 janus at gcc dot gnu dot org
  2009-06-13 11:33 ` [Bug fortran/40427] " janus at gcc dot gnu dot org
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: janus at gcc dot gnu dot org @ 2009-06-12 13:14 UTC (permalink / raw)
  To: gcc-bugs

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


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2009-06-24 11:03 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-06-12 13:14 [Bug fortran/40427] New: [F03] Procedure Pointer Components with OPTIONAL arguments janus at gcc dot gnu dot org
2009-06-13 11:33 ` [Bug fortran/40427] " janus at gcc dot gnu dot org
2009-06-19  7:32 ` burnus at gcc dot gnu dot org
2009-06-24 11:00 ` janus at gcc dot gnu dot org
2009-06-24 11:03 ` janus at gcc dot gnu dot org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).