11-108r2
To: J3
From: Nick Maclaren/Bill Long
Subject: Interop TR: dim member validity - UTI TR6
Date: 2011 February 17
Reference: N1838, 10-235
Even if the approach in 10-235 is not taken, the issue of constraints on
what dim values can be passed from C to Fortran needs to be resolved.
As I understand it, the constraints on the extent and sm fields are as I
described in 10-235:
All strides in the bounds array shall be non-zero. There shall be a
reordering of the dimensions such that the absolute value of the
stride of one dimension is not less than the absolute value of the
stride of the previous dimension multiplied by the extent of the
previous dimension.
There is nothing in N1838.pdf that requires that. It does not even
require distinct elements not to alias each other, as in:
elem_len = 1
dim[0].extent = 100
dim[0].sm = 2
dim[1].extent = 100
dim[2].sm = 5
A nastier case is descriptors where no elements overlap but dimensions
do - which begs the question of whether Fortran compilers should be
required to accept such descriptors, diagnose them, or what? For
example:
elem_len = 8
dim[0].extent = 10
dim[0].sm = 88
dim[1].extent = 10
dim[2].sm = 104
In addition, there is some dislike for the term "stride multiplier"
used in reference to the sm member of the dim struct. The term
"stride" is already given a formal meaning in the Fortran standard, so
a conflicting use of that term here is unwise. Proposal: refer to the
sm members as "memory stride".
The requirement that the memory stride be non-zero conflicts with the
design of using the element length as the length of a character
variable, since it is possible to create a character string of length
0 in Fortran.
The edits in this paper resolve UTI TR6.
Edits to N1838:
[10:8], [10:12-13], [10:18], and in the description of the
CFI_INVALID_SM macro in Table 5.3 on page 14, replace "stride
multiplier" with "memory stride".
[10:19+] After the description of CFI_index_t sm, add a new paragraph:
"There shall be an ordering of the dimensions such that the absolute
value of the sm value of one dimension is not less than the absolute
value of the sm value of the previous dimension multiplied by the
extent of the previous dimension."
[10:19+] {Note to editor: delete UTI TR6.}