This is the mail archive of the mailing list for the GNU Fortran 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]

Re: C interoperability and C_LOC intrinsic

On Sunday 19 September 2010 02:40:49 David Car wrote:
> It really boils down to my interpretation of the latest standard which
> is most likely in error.  The ISO/IEC SC22/WG5/N1776 document, in
> section, that I have states for the C_LOC intrinsic:
> " 3 Argument. X shall have either the POINTER or TARGET attribute. It
> shall not be a coindexed object. It shall
> either be a variable with interoperable type and kind type parameters,
> or be a scalar, nonpolymorphic variable
> with no length type parameters. If it is allocatable, it shall be
> allocated. If it is a pointer, it shall be associated.
> If it is an array, it shall be contiguous and have nonzero size. It
> shall not be a zero-length string."
> So, it seems that the interpretation is that an argument with the
> POINTER attribute can only be a scalar.  This is enforced while
> looking through resolve.c at the following code snippet from the
> gfc_iso_c_func_interface function:
>              else if (arg_attr.pointer
>                        && is_scalar_expr_ptr (args->expr) != SUCCESS)
>                 {
>                   /* Case 1c, section, J3/04-007: an
> associated
>                      scalar pointer.  */
>                   gfc_error_now ("Argument '%s' to '%s' at %L must be an "
>                                  "associated scalar POINTER",
> args_sym->name, sym->name, &(args->expr->where)); retval = FAILURE;
>                 }
> I guess it centers around the "interoperable" type characteristic.  So
> an associated pointer to an array is considered not interoperable?  

Interoperable entities are dealt with in section 15.3.
Here, you are most interested in subsection 15.3.6 (interoperability of array 
variables) which has as note 15.16:

An allocatable array or array pointer is never interoperable. Such an array 
does not meet the requirement of being an explicit-shape or assumed-size 

> I
> could say why this could be the case because you could have an
> instance where your are viewing just a slice of the array with the
> pointer, but I would rely on the programmer to make that assurance.
I wouldn't ;-)


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