AW: [patch,wip] warn on noncontiguous pointers

N.M. Maclaren nmm1@cam.ac.uk
Fri Sep 28 16:59:00 GMT 2018


On Sep 28 2018, Bader, Reinhold wrote:
>> 
>> >> If we go down the list, we see that fptr1(4:) is not contiguous; it
>> >> is not an array (it is a pointer), so (4) also does not apply.
>> > I don't agree with this conclusion. First, the array and pointer
>> > properties are not mutually exclusive (they are conveyed by specifying
>> > the DIMENSION and POINTER attribute, independently).
>> 
>> Can you maybe elaborate a bit more?
>> 
>> I see that you can associate a pointer with a target (6.7.1.4), which 
>> of course can be an array. But I have not found anything in the standard 
>> that says that a pointer to an array is an array.
>
> OK. Looking at 5.3.8.1 (Fortran 2008 for the sake of this discussion), we 
> have that an object that has the DIMENSION attribute is an array. 
> array-spec includes deferred-shape-spec-list, so any object declared with 
> deferred shape is an array.
>
> 5.3.8.4 then says C532 An array with the POINTER or ALLOCATABLE attribute 
> shall have an array-spec that is a deferred-shape-spec-list.
>
> and then has further text to say at what point things like SHAPE or SIZE 
> of such an object become defined.
>
>It can't get any clearer than that. 

My guess is that the root cause of the confusion is the phrasing 'pointer 
to an array', because that implies a model in which the pointer is 
separate. It's better called an array pointer, where the two properties are 
inseparable (for that name), and the comment "it is not an array (it is a 
pointer)" is not correct - it's both. Attributes are not qualifiers in the 
C sense.

That's why several of us who teach Fortran tell C and C++ programmers that
they will first have to unlearn much of what they know - the language's
abstract model is extremely different!


Regards,
Nick Maclaren.




More information about the Fortran mailing list