Consider the following program:
parabrisas:~/test% cat C578.f
subroutine s( )
Under constraint C578 of the f95 standard this is illegal, since a global save
is not permitted in the same scoping unit as any other explicit use of the
save attribute or save statement. gfortran correctly recognises this and
diagnoses an error.
However, this constraint did not exist in F77 (I am unsure about F90).
Therefore, the above is a perfectly legal F77 program (and, indeed g77
compiles it without complaint).
Brief correction - the reference to C578 is actually from the F2003 standard.
In f95 is it is the second, unnumbered, constraint in section 5.2.4.
f90 has the same constraint as f95 at least that is what ICC reports.
Fortran 77 also forbids the behavior. It looks like the
code is illegal, and g77 contains a bug.
In the Fortran 77 standard (ANSI X3.9-1978) I could not find any sentence that
indicates that a SAVE statement without a list cannot appear in the same program
unit as a SAVE statement with a list of variables. I would conclude that
gfortran does NOT compile valid F77 code. Code which, by the way, is not only
g77 but by commercial compilers as well.
Please be more specific if you think that I am wrong.
(In reply to comment #5)
> In the Fortran 77 standard (ANSI X3.9-1978) I could not find any sentence
> indicates that a SAVE statement without a list cannot appear in the same
> unit as a SAVE statement with a list of variables.
> Please be more specific if you think that I am wrong.
Please see the thread on the gfortran mailing list, starting at
The definitive answer is probably Richard Maine's at:
In brief, the code is almost certainly illegal - but since g77 compiles it (as
do several other compilers), it is a clear regression for gfortran to not
allow its compilation (albeit not under -std=f95)
*** Bug 21434 has been marked as a duplicate of this bug. ***
Fixed for 4.1 by:
* decl.c (gfc_match_save): Changed duplicate SAVE errors to
warnings in the absence of strict standard conformance
* symbol.c (gfc_add_save): Same.