(j3.2006) Comment 2 from TS Ballot
Bader, Reinhold
Reinhold.Bader
Mon Sep 10 17:22:22 EDT 2012
> -----Urspr?ngliche Nachricht-----
> Von: Bill Long [mailto:longb at cray.com]
> Gesendet: Montag, 10. September 2012 23:02
> An: Bader, Reinhold
> Betreff: Re: AW: (j3.2006) Comment 2 from TS Ballot
>
>
>
> On 9/10/12 3:44 PM, Bader, Reinhold wrote:
> > How about
> >
> > "If a formal parameter of type CFI_cdesc_t * corresponds to a dummy
> > argument in an interoperable procedure interface, indirection on a
> > pointer derived from its base_addr member by pointer arithmetic valid
> > in C is allowed if and only if the value of that pointer can be obtained
> > by applying the function CFI_address (8.3.5.2) to the object or a subobject of
> it."
> > ?
> >
> > This makes it more clear that C pointer arithmetic underlies additional
> > restrictions when operating on objects coming in from Fortran. I've also
> > turned CFI_cdesc_t into a pointer type since that appears more appropriate.
> >
>
> I used "pointer to CFI_cdesc_t" to parallel the usage in 8.7 where we
> talk about interoperable interfaces.
OK.
>
> The problem with the indirection language is that if you have
>
> float *p1;
> float *p2;
>
> // and a formal parameter arg that is a pointer to CFI_cdesc_t that
> describes a float array
>
> p2 = arg->base_addr
> p1 = (float) malloc(1000);
>
> p2 = p2 + p1 - arg->base_addr;
>
> then the rule appears to prohibit using p2 to access the local array.
> I'm not convinced that the new wording is any better. There are just
> too many valid ways of doing pointer arithmetic in C.
I'm obviously not sufficiently imaginative :-) Your example seems to indicate some words are needed to
only deal with the range base_addr (first element) to base_addr (last element). Would
"If a formal parameter that is a pointer to CFI_cdesc_t corresponds to a dummy
argument in an interoperable procedure interface, indirection on a
pointer derived from its base_addr member by pointer arithmetic that is
a valid address within the C object starting at base_addr
is allowed if and only if the value of that pointer can be obtained
by applying the function CFI_address (8.3.5.2) to the object or a subobject of it."
be precise enough?
>
> Cheers,
> Bill
>
>
>
> > Regards
> > Reinhold
> >
> >> -----Urspr?ngliche Nachricht-----
> >> Von: j3-bounces at mailman.j3-fortran.org [mailto:j3-bounces at mailman.j3-
> >> fortran.org] Im Auftrag von Bill Long
> >> Gesendet: Montag, 10. September 2012 22:28
> >> An: fortran standards email list for J3
> >> Betreff: (j3.2006) Comment 2 from TS Ballot
> >>
> >> The ISO ballot on the DTS for TS 29133 (Interoperability TS) resulted
> >> in a total of two comments, both technical and from Germany. We
> >> need to create a document containing responses to these comments.
> >>
> >> The following starts the discussion of the second comment. Please,
> >> especially Reinhold, post to the list if you think I have misunderstood
> >> the intent of the comment.
> >>
> >>
> >> -------From the Ballot Response for Comment 2-----------------
> >>
> >> Technical comment 1 from Germany:
> >>
> >> For an entity of [a pointer to] type CFI_cdesc_t that corresponds to a
> >> non-contiguous Fortran object, accessing parts of the object that would
> >> not be accessible in Fortran must be explicitly disallowed, because the
> >> base_addr member is exposed.
> >>
> >> Proposed change:
> >>
> >> In 8.5, after para 3, add a para 4:
> >> "If a formal parameter of type CFI_cdesc_t corresponds to a dummy
> >> argument in an interoperable procedure interface, indirection on a
> >> pointer calculated from its base_addr member is allowed if and only if
> >> the value of that pointer can be obtained by applying the function
> >> CFI_address (8.3.5.2) to the object or a subobject of it."
> >>
> >>
> >> -------End of Ballot Response for Comment 2-------------------
> >>
> >> Discussion:
> >>
> >> I had thought that we had something similar to this in the TS in the
> >> past, but I'm not finding it now. I'm concerned that "calculated
> >> from" in the edit is sufficiently vague that the paragraph is not really
> >> a solution to the problem. The real objective is to permit access to
> >> only elements of the actual argument corresponding to the dummy argument
> >> in the interoperable procedure interface. Maybe:
> >>
> >> "If a formal parameter that is a pointer to CFI_cdesc_t corresponds to a
> >> dummy argument in an interoperable interface, a computed pointer may be
> >> used to access the corresponding actual argument, or a subobject of it,
> >> if and only if the value of the computed pointer can be obtained by
> >> applying the function CFI_address (8.3.5.2) to the formal parameter."
> >>
> >> Comments...
> >>
> >>
> >> Cheers,
> >> Bill
> >>
> >>
> >> --
> >> Bill Long longb at cray.com
> >> Fortran Technical Support & voice: 651-605-9024
> >> Bioinformatics Software Development fax: 651-605-9142
> >> Cray Inc./Cray Plaza, Suite 210/380 Jackson St./St. Paul, MN 55101
> >>
> >>
> >> _______________________________________________
> >> J3 mailing list
> >> J3 at mailman.j3-fortran.org
> >> http://mailman.j3-fortran.org/mailman/listinfo/j3
>
> --
> Bill Long longb at cray.com
> Fortran Technical Support & voice: 651-605-9024
> Bioinformatics Software Development fax: 651-605-9142
> Cray Inc./Cray Plaza, Suite 210/380 Jackson St./St. Paul, MN 55101
>
More information about the J3
mailing list