This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug fortran/36759] C_LOC and characters greater then one in length.
- From: "brtnfld at hdfgroup dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 8 Jul 2008 17:43:53 -0000
- Subject: [Bug fortran/36759] C_LOC and characters greater then one in length.
- References: <bug-36759-16432@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Comment #2 from brtnfld at hdfgroup dot org 2008-07-08 17:43 -------
Subject: Re: C_LOC and characters greater then one in
length.
My mistake, I did not see that in the standard.
It still would be nice however to have the non-standard feature for
characters of LEN > 1.
burnus at gcc dot gnu dot org wrote:
> ------- 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