http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49112
--- Comment #8 from John <jwmwalrus at gmail dot com> 2011-05-28 16:28:15 UTC --- (In reply to comment #5) > (In reply to comment #4) > > SAVE can be either a statement or an attribute. When it's statement, it > > affects all the variables within the containing unit > > Yes, of course. I completely forgot about this possibility. > > Btw, the code in comment #3 works with gfortran 4.5, so it is in fact a > regression. > > > > The standard also allows the confirmation, as an attribute, of the SAVE at > > the > > module level, so, for a "triple save" example: > > > > module t1_mod > > save > > > > type :: t1 > > integer :: dummy = 0 > > end type > > > > type(t1), save :: a = t1(2), b = t1(3) > > end type Sorry, it should have been "end module" > > > > > > Which also triggers a duplicate save warning. > > This is at best a "double save", and I think the (F08) standard forbids it: > > C580 (R553) 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. > t > So I think in this case gfortran correctly complains about a "Duplicate SAVE > attribute". Ups... I completely forgot about that constraint (I must have been thinking about section 5.3.16, which mentions an implicit SAVE statement for modules, and that one can be explicitly confirmed). So yes, it's at best an extension to the standard. Intel's and Sun's compilers complain about it: ...:~$ ifort -stand -c t1.f90 t1.f90(8): warning #7652: The F2003 standard says that the SAVE attribute is invalid since there is an occurrence of a SAVE statement with an omitted save-entity-list in the same scoping unit. [SAVE] type(t1), save :: a = t1(2), b = t1(3) ...:~$ sunf95 -ansi -c t1.f90 type(t1), save :: a = t1(2), b = t1(3) ^ "t1.f90", Line = 8, Column = 15: ANSI: The Fortran standard requires a SAVE statement with no saved-entity-list to be the only SAVE in the scoping unit. One thing about the original code, is that the "duplicate save" warning is being issued for an entity with the PARAMETER attribute ---so the SAVE at the scoping unit shouldn't even affect it, since the entity is not really a variable.