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

brtnfld at hdfgroup dot org gcc-bugzilla@gcc.gnu.org
Tue Jul 8 17:44:00 GMT 2008



------- 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



More information about the Gcc-bugs mailing list