This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug fortran/36759] C_LOC and characters greater then one in length.



------- Comment #1 from burnus at gcc dot gnu dot org  2008-07-07 22:41 -------
>   A = c_loc(arg1)
>            1
> Error: CHARACTER argument 'arg1' to 'c_loc' at (1) must have a length of 1
> 
> I'm not sure where this restriction comes from (it's not part of the standard).

One could argue that one should allow it as vendor extension, however, the
restriction is in the standard:

"Interoperability of intrinsic types"
"A Fortran intrinsic type with particular type parameter values is
interoperable with a C type if the type and kind type parameter value are
listed in the table on the same row as that C type; if the type is character,
interoperability also requires that the length type parameter be omitted or be
specified by an initialization expression whose value is one."

For interoperability one thus should use instead of
  character(len=2) :: str
rather
  character(len=1,kind=c_char) :: str(2)

(This is also the case for dummy arguments of BIND(C) procedures, though there
one can as pass "a string" as actual argument, cf. "storage sequence".)


-- 


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]