j3-fortran / fortran_proposals

Proposals for the Fortran Standard Committee
175 stars 14 forks source link

F2018 constraint C889 is apparently pointless, rarely enforced, and should be removed #266

Open klausler opened 2 years ago

klausler commented 2 years ago

"C889 (R856) If a SAVE statement with an omitted saved entity list appears in a scoping unit, no other appearance of the SAVE attr-spec or SAVE statement is permitted in that scoping unit."

So a bare SAVE statement in a scoping unit does not (just) mean that any other SAVE statement or SAVE attribute in that scoping unit is redundant -- it somehow means that they are errors.

Why is that a necessary error?

It elicits a warning from GNU Fortran, an error from NAG, and silence from all other compilers.

module m
  save
  integer, save :: n
end module

program main
  use m
  print *, 'ok'
end