Ian Bush said:
And as I understand it in earlier Fortran the iteration count for a
"zero-trip" loop was undefined, but many implementations performed as
above,
More precisely, code that had a "zero-trip loop count" was nonconforming
to the f66 ANSI standard. It was not just that the resulting loop count
was undefined, the entire behavior of the program was undefined, as with
any other nonstandard code. This is commonly misunderstood, with the
misunderstanding even making its way into compiler switch names, which
probably then reinforced user misunderstandings. As noted, f77
standardized such code, with the zero-trip interpretation.
I've seen f77 and later compilers where a switch named -f66 did nothing
other than change zero-trip DO loops to be implemented with one trip.
That always struck me as a misleading switch name because that was *NOT*
one of the areas where the f77 standard was incompatible with f66. The
f77 standard has an annex listing the incompatibilities, and that isn't
in it, insomuch as giving an interpretation to formerly nonstandard code
does not count as an incompatibility. The -f66 compiler switch in
question did nothing about any of the actual incompatibilities between
the standards.
This probably traces back to people confusing particular compiler
implementations with the standard. That was more common in the days of
f66 than it is now. Before f66, of course, there was no formal standard
- just particular implementations, some of which were dominant enough to
amost constitute defacto standards.