On Jan 19, 2006, at 8:50 AM, Catherine Moroney wrote:
> I've encountered a "feature" in the SGI MipsPro F90
> compiler and would like to know what other compilers
> make of this, and whether the behaviour of the SGI
> compiler conforms to the standard.
This behavior (initialization implies save) is not only allowed by the
f90 standard, it is *REQUIRED*. The compiler would be non-conforming if
it didn't do it. The behavior is allowed (and was very common) in f77,
but you "can't tell" with a legal f7 program.
The feature was new to f90... and I might add that it had the effect of
making some "f77" programs that weren't standard-conforming (but
happened to work on most compilers) be standard-conforming. It was a
very common f77 idiom to do this, but "forgot" (or otherwise omit) the
SAVE statement that was technically required in f77.
My personal style is to make SAVE explicit. But there sure are a lot of
"f77" codes from other people that didn't follow that style. I quote
the "f77" because they weren't standard-conforming programs.
Note that there are *NO* cases where this feature makes f77
standard-conforming programs fail. If you had a program that depended
on the lack of this feature, then that program was non-standard. That's
because without the SAVE attribute, the variable becomes undefined when
the routine exits. That does *NOT* mean that it gets reinitialized n
the next entry. Instead, that means that it is illegal for your program
to reference it until you do something to define it. A valid f77
program couldn't tell whether it kept its value, was reinitialized, got
a random garbage value from the stack, or whatever... because looking
at all made your program invalid.
Of course, you can look in debuggers and other extra-standard means,
but that's different.
--
Richard Maine | Good judgment comes from experience;
[log in to unmask] | experience comes from bad judgment.
| -- Mark Twain
|