Consider the following code:

module test

  type :: t
  end type t

  type, extends(t) :: tt
  end type tt

contains

  subroutine get_cptr(tt_cptr)
    use iso_c_binding
    type(c_ptr) :: tt_cptr
    class(t), pointer :: tt_fptr
    allocate(tt::tt_fptr)
    if (associated(tt_fptr)) tt_cptr = c_loc(tt_fptr)
  end subroutine get_cptr

end module test

At compile-time (using gcc trunk r162082) this gives "Error: Parameter
'tt_fptr' to 'c_loc' at (1) must be either a TARGET or an associated pointer"
even though it has to pass the "if (associated(tt_fptr))" test to execute the
"c_loc" function.


-- 
           Summary: [OOP] CLASS pointer reported unassociated to C_LOC
           Product: gcc
           Version: 4.6.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: barron dot bichon at swri dot org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44925

Reply via email to