"Russell, Richard" <[log in to unmask]> wrote:
> I noticed something in the LF95 language manual (rev. F, p.90), under
> COMMON. "Execution of a RETURN or END statement can cause data objects
> in a named common to become undefined unless the common block name has
> been declared in a SAVE statement." This strikes me as peculiar....
>
> So, can someone explain the statement in the manual?... I can't imagine
> how data in a named COMMON could be lost upon return if the data are to
> be "common" with other routines.
This may be confusing because, although true, the passage you quote from
the LF95 manual, is only half of the story. The important distinction is
"can" instead of "does".
Common variables are allowed to become undefined if no scoping unit that
accesses the common block is in execution. So if the main program calls
A and A calls B, and A and B declare the same common block, but don't give
it the SAVE attribute, and it's not declared in the main program, the values
defined in it by A and B remain defined until A returns to the main program.
At that instant the processor is permitted to undefine the varables in the
common block. It IS NOT allowed to undefine the common variables when B
returns because A is still "in execution."
If a variable becomes storage associated with another variable that has
different type -- either by equivalence or common, assigning to one causes
the other to become undefined, atleast in the sense that the value has a
meaning defined by the standard.
The same story holds for module variables.
|