(j3.2006) CFI_index_t

Robert Corbett robert.corbett
Fri Feb 10 19:59:22 EST 2012


On 02/10/12 08:07, Bill Long wrote:
>
>
> On 2/10/12 2:14 AM, Robert Corbett wrote:
>> The definition given for CFI_index_t in Clause 8.3.2 of the draft
>> Further C Interoperability TS is not clear. The definition is
>>
>> CFI_index_t is a typedef name for a standard signed integer type
>> capable of representing the result of subtracting two pointers.
>>
>
> Which was carefully crafted by our C expert.

Yes, and the Fortran standard is carefully crafted by Fortran experts.
>
> For me, it has the right operational content.  Things declared CFI_index_t  
> are typically values you want to add to, or subtract from, an existing pointer 
> to get a new pointer that points to the object you are attempting to access.  
> Seems to me the definition says exactly the right thing.

Our interpretations differ.  I think of items of the type CFI_index_t as 
expressing lower bounds, extents, and stride multipliers (expressed in bytes).
>
>> I assume the definition does not mean the result of subtracting two
>> arbitrary pointers. I assume that the definition assumes something like
>> the definition of pointer subtraction provided in the C standard, but
>> extended to handle cases not defined by the C standard. One important
>> issue is whether the definition is based on pointers to elements of C
>> arrays or pointers to elements of Fortran arrays. For some Fortran
>
> Objects declared with CFI_index_t are always in the C domain.  These are C 
> pointers we're taking about.
>
>> processors and C companion processors, that difference will make a
>> difference in the required size of the integer type. Here is my best
>
> A C processor that has a different addressing range from a Fortran processor 
> is a pretty poor choice as a "companion" processor.     This would break even 
> the F2003 form of interoperability.

I do not see how this comment relates to anything I wrote.

The point I tried to make was that a Fortran processor and its C companion 
processor might have different limits on the number of elements
of size greater than zero allowed in an array.  For example, MSVC for 32-bit 
Windows allows an array of char to have nearly three billion elements.  The 
Fortran implementations I tested on 32-bit Windows had limits of 2^31 - 1 or 
less on the number of elements allowed in an array whose elements were not 
zero-sized.  If the pointer differences were for Fortran objects, the 
differences between pointers to parts of a single object could be represented 
using 32-bit signed integers.  A vendor implementing the TS for such an 
environment might think the TS would allow the type name CFI_index_t to denote 
the 32-bit signed integer type.  If the intended meaning is that the type must 
be capable of representing difference between two parts of a C object, the type 
name must name a type that is larger than 32 bits.  I do not think the current 
draft of the TS makes this clear.

Bob Corbett
>
>> guess at the intended meaning of the definition:
>>
>> CFI_index_t is a typedef name for a standard signed integer type
>> capable of representing the integers from -N to N, where N is the
>> largest number of elements the Fortran processor supports for an
>> array whose elements are not zero-sized.
>>
>> I can easily imagine that I have not correctly guessed the intended
>> meaning. If that is the case, please let me know how my proposed
>> definition differs from the intended meaning.
>>
>> Robert Corbett
>> _______________________________________________
>> J3 mailing list
>> J3 at j3-fortran.org
>> http://j3-fortran.org/mailman/listinfo/j3
>




More information about the J3 mailing list