10-229 To: J3 From: Nick Maclaren Subject: Interop TR: CFI_is_contiguous Date: 2010 October 07 Reference: 10-165r2.pdf One comment that was made by at least Aleks Donev and Reinhold Bader in N1766 was that CFI_is_contiguous should return the contiguity rather than assigning it through an argument. Exactly like CFI_address (as will be proposed in a paper by John Reid to address requirement 1 of N1820), it is a pure function that returns a simple value, which is unlike all of the other CFI_functions. It would be better to match that. It has been said that it might want to return an error indication for unallocated or disassociated arrays, but that argument applies identically to CFI_address. It is also extremely user-hostile, and means that the following simple use: if (CFI_is_contiguous(cdesc)) ... changes into: int temp; if (CFI_is_contiguous(cdesc,&temp) && temp) ... There are also subtle gotchas in the C language to do with calling functions that have side-effects in arbitrary expressions, and they regularly cause trouble in combination with optimisation. They are unlikely to affect the other functions, as those are 'statement-like', unlike CFI_address and CFI_is_contiguous. A related point is that it is a mistake to specify the assumption that all functions that return int will NECESSARILY be returning an error indicator. One cannot predict the future, but there is no need to restrict future enhancements unecessarily. Edits to 10-165r2: [11:9] Change the line to: "If an error occurs during execution of a function that returns an int value as an error indicator, the returned value is". [11:14-17] Replace the specification of CFI_is_contiguous by: "5.2.6.4 int CFI_is_contiguous ( const CFI_desc_t * ); Description. CFI_is_contiguous returns 1 if the object described by the C descriptor can be determined to be contiguous, and 0 otherwise." [12:7] Append to the end of the paragraph "The result is an error indicator." [12:13] Append to the end of the paragraph "The result is an error indicator." [12:17] Append to the end of the paragraph "The result is an error indicator." [12:23] Append to the end of the paragraph "The result is an error indicator." [12:29] Append to the end of the paragraph "The result is an error indicator."