Simple problem on array indices
N.M. Maclaren
nmm1@cam.ac.uk
Sat Jan 11 12:05:00 GMT 2014
On Jan 9 2014, Salvatore Filippone wrote:
>Adam Hirst wrote:
>> I'd be surprised if weren't rules in the standard about whether
>> array-valued indices are allowed to >alias, because if they are it just
>> sounds like it's allowing all kinds of ambiguous problems like this. >I
>> look forward to what other people in the list have to say, this is
>> interesting.
>
>Indeed, vector subscripts with repeated indices are not allowed as
>LHS, hence the code is invalid (for precisely the reasons meniioned by
>Adam) and the compiler is free to do whatever it wants.
>See:
>Metcalf & Reid & Cohen, section 6.13
>Adams et al, F2003 Handbook, section 6.6.4.3 (which should correspond
>to the standard section numbering)
It's stronger than that. It is undefined, and the program is likely to
blow up or give completely wrong answers under some circumstances. What
is more, gfortran may well give different results with different options
or on different systems. No matter WHAT happens, it's not a bug in the
compiler!
Regards,
Nick Maclaren.
More information about the Fortran
mailing list