public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/42072]  New: [F03] wrong-code with C_F_PROCPOINTER
@ 2009-11-16 22:48 janus at gcc dot gnu dot org
  2009-11-16 22:51 ` [Bug fortran/42072] " janus at gcc dot gnu dot org
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: janus at gcc dot gnu dot org @ 2009-11-16 22:48 UTC (permalink / raw)
  To: gcc-bugs

The following variant of proc_ptr_8.* fails at runtime:


! { dg-do run }
! { dg-additional-sources proc_ptr_8.c }

MODULE X

  USE ISO_C_BINDING
  INTERFACE
    INTEGER(KIND=C_INT) FUNCTION mytype( a ) BIND(C)
       USE ISO_C_BINDING
       INTEGER(KIND=C_INT), VALUE :: a
    END FUNCTION
    SUBROUTINE init() BIND(C,name="init")
    END SUBROUTINE
  END INTERFACE

  TYPE(C_FUNPTR), BIND(C,name="funpointer") :: funpointer

END MODULE X

USE X
PROCEDURE(mytype), POINTER :: ptype

CALL init()
call setpointer(ptype)
if (ptype(3) /= 9) call abort()

contains

  subroutine setpointer (p)
    PROCEDURE(mytype), POINTER :: p
    CALL C_F_PROCPOINTER(funpointer,p)
  end subroutine

END

! { dg-final { cleanup-modules "X" } }


/* Used by proc_ptr_8.f90.
   PR fortran/32580.  */

int (*funpointer)(int);

int f(int t)
{
  return t*3;
}

void init()
{
 funpointer=f;
}


-- 
           Summary: [F03] wrong-code with C_F_PROCPOINTER
           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=42072


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

end of thread, other threads:[~2009-11-20 16:08 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-11-16 22:48 [Bug fortran/42072] New: [F03] wrong-code with C_F_PROCPOINTER janus at gcc dot gnu dot org
2009-11-16 22:51 ` [Bug fortran/42072] " janus at gcc dot gnu dot org
2009-11-16 22:56 ` janus at gcc dot gnu dot org
2009-11-16 23:00 ` pinskia at gcc dot gnu dot org
2009-11-16 23:00 ` pinskia at gcc dot gnu dot org
2009-11-17 12:00 ` janus at gcc dot gnu dot org
2009-11-18 13:25 ` janus at gcc dot gnu dot org
2009-11-20 15:51 ` janus at gcc dot gnu dot org
2009-11-20 16:08 ` 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).