public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/33497]  New: Bind(C): C_LOC rejects interoperable arguments
@ 2007-09-19 12:17 burnus at gcc dot gnu dot org
  2007-09-19 17:29 ` [Bug fortran/33497] " sfilippone at uniroma2 dot it
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: burnus at gcc dot gnu dot org @ 2007-09-19 12:17 UTC (permalink / raw)
  To: gcc-bugs

See http://gcc.gnu.org/ml/fortran/2007-09/msg00301.html
for the initial bug report by Salvatore Filippone (thanks for finding the bug!)
and a longer example.

Assume the following code:

  type double_vector_item
    real(c_double), allocatable :: v(:)
  end type double_vector_item
  type(double_vector_item), target :: dbv_pool

While V(:) itself is does not have the TARGET attribut, dbv_pool%v has it due
to the following clause in the Fortran 2003 standard ("5.1.2.14 TARGET
attribute"):

"If an object has the TARGET attribute, then all of its nonpointer subobjects
also have the TARGET attribute."

Additionally, "real(c_double)" is of interoperable type and kind; thus the
following clause of "15.1.2.5 C LOC (X)" applies to dbv_pool%v:

"Argument. X shall [...] (1) have interoperable type and type parameters and be
[...] (b) an allocated allocatable variable that has the TARGET attribute and
is not an array of zero size".

I did not investigate in detail, but gfortran seems to fail (in resolve.c's
gfc_iso_c_func_interface) at

          /* See if we have interoperable type and type param.  */
          if (verify_c_interop (&(args->expr->symtree->n.sym->ts),
                                args->expr->symtree->n.sym->name,
                                &(args->expr->where)) == SUCCESS
              || gfc_check_any_c_kind (&(args_sym->ts)) == SUCCESS)

Notes:
- dbv_pool itself is not C interoperable as it has no BIND(C) - at it cannot
have this attribute at V is allocatable.
- V cannot have an explicit TARGET attribute as it is a TYPE component
- sunf95 has the same problem as gfortran, but ifort 10, NAG f95 and g95 accept
this program.


-- 
           Summary: Bind(C): C_LOC rejects interoperable arguments
           Product: gcc
           Version: 4.3.0
            Status: UNCONFIRMED
          Keywords: rejects-valid
          Severity: normal
          Priority: P3
         Component: fortran
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: burnus at gcc dot gnu dot org
OtherBugsDependingO 32630
             nThis:


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


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

* [Bug fortran/33497] Bind(C): C_LOC rejects interoperable arguments
  2007-09-19 12:17 [Bug fortran/33497] New: Bind(C): C_LOC rejects interoperable arguments burnus at gcc dot gnu dot org
@ 2007-09-19 17:29 ` sfilippone at uniroma2 dot it
  2007-09-19 23:15 ` patchapp at dberlin dot org
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: sfilippone at uniroma2 dot it @ 2007-09-19 17:29 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from sfilippone at uniroma2 dot it  2007-09-19 17:29 -------
A version with an inner pointer to a derived type instead of allocatable array
fails as well.
-----------------
module c_vhandle_mod
  use iso_c_binding
  type foo
    integer :: i
  end type foo  
  type foo_item
    type(foo), pointer  :: v=> null()
  end type foo_item
  type(foo_item), allocatable :: foo_pool(:)

contains 

  type(c_ptr) function get_foo_address(handle)
    integer(c_int), intent(in) :: handle    
    get_foo_address = c_loc(foo_pool(handle)%v)    
  end function get_foo_address

end module c_vhandle_mod
------------------------- 
[sfilippo@localhost bugtest]$ /usr/local/gcc43/bin/gfortran -c c_vh_2_mod.f90 
c_vh_2_mod.f90:18.28:

    get_foo_address = c_loc(foo_pool(handle)%v)
                           1
Error: Parameter 'foo_pool' to 'c_loc' at (1) must be either a TARGET or an
associated pointer


-- 


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


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

* [Bug fortran/33497] Bind(C): C_LOC rejects interoperable arguments
  2007-09-19 12:17 [Bug fortran/33497] New: Bind(C): C_LOC rejects interoperable arguments burnus at gcc dot gnu dot org
  2007-09-19 17:29 ` [Bug fortran/33497] " sfilippone at uniroma2 dot it
@ 2007-09-19 23:15 ` patchapp at dberlin dot org
  2007-09-20 11:51 ` burnus at gcc dot gnu dot org
  2007-09-20 11:55 ` burnus at gcc dot gnu dot org
  3 siblings, 0 replies; 5+ messages in thread
From: patchapp at dberlin dot org @ 2007-09-19 23:15 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from patchapp at dberlin dot org  2007-09-19 23:15 -------
Subject: Bug number PR 33497

A patch for this bug has been added to the patch tracker.
The mailing list url for the patch is
http://gcc.gnu.org/ml/gcc-patches/2007-09/msg01583.html


-- 


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


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

* [Bug fortran/33497] Bind(C): C_LOC rejects interoperable arguments
  2007-09-19 12:17 [Bug fortran/33497] New: Bind(C): C_LOC rejects interoperable arguments burnus at gcc dot gnu dot org
  2007-09-19 17:29 ` [Bug fortran/33497] " sfilippone at uniroma2 dot it
  2007-09-19 23:15 ` patchapp at dberlin dot org
@ 2007-09-20 11:51 ` burnus at gcc dot gnu dot org
  2007-09-20 11:55 ` burnus at gcc dot gnu dot org
  3 siblings, 0 replies; 5+ messages in thread
From: burnus at gcc dot gnu dot org @ 2007-09-20 11:51 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from burnus at gcc dot gnu dot org  2007-09-20 11:50 -------
Subject: Bug 33497

Author: burnus
Date: Thu Sep 20 11:50:39 2007
New Revision: 128620

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=128620
Log:
2007-09-20  Christopher D. Rickett  <crickett@lanl.gov>

        PR fortran/33497
        * resolve.c (gfc_iso_c_func_interface): Use information from
        subcomponent if applicable.

2007-09-20  Christopher D. Rickett  <crickett@lanl.gov>

        PR fortran/33497
        * gfortran.dg/c_loc_tests_11.f03: New test case.


Added:
    trunk/gcc/testsuite/gfortran.dg/c_loc_tests_11.f03
Modified:
    trunk/gcc/fortran/ChangeLog
    trunk/gcc/fortran/resolve.c
    trunk/gcc/testsuite/ChangeLog


-- 


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


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

* [Bug fortran/33497] Bind(C): C_LOC rejects interoperable arguments
  2007-09-19 12:17 [Bug fortran/33497] New: Bind(C): C_LOC rejects interoperable arguments burnus at gcc dot gnu dot org
                   ` (2 preceding siblings ...)
  2007-09-20 11:51 ` burnus at gcc dot gnu dot org
@ 2007-09-20 11:55 ` burnus at gcc dot gnu dot org
  3 siblings, 0 replies; 5+ messages in thread
From: burnus at gcc dot gnu dot org @ 2007-09-20 11:55 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from burnus at gcc dot gnu dot org  2007-09-20 11:54 -------
Fixed on 4.3 (trunk).


-- 

burnus at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |FIXED


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


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

end of thread, other threads:[~2007-09-20 11:55 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-09-19 12:17 [Bug fortran/33497] New: Bind(C): C_LOC rejects interoperable arguments burnus at gcc dot gnu dot org
2007-09-19 17:29 ` [Bug fortran/33497] " sfilippone at uniroma2 dot it
2007-09-19 23:15 ` patchapp at dberlin dot org
2007-09-20 11:51 ` burnus at gcc dot gnu dot org
2007-09-20 11:55 ` burnus 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).