http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55207
--- Comment #3 from janus at gcc dot gnu.org 2012-11-04 22:48:37 UTC --- The following patch applies the implicit SAVE attribute to variables declared in the main program: Index: gcc/fortran/decl.c =================================================================== --- gcc/fortran/decl.c (revision 193137) +++ gcc/fortran/decl.c (working copy) @@ -3812,9 +3812,11 @@ match_attr_spec (void) } } - /* Since Fortran 2008 module variables implicitly have the SAVE attribute. */ - if (gfc_current_state () == COMP_MODULE && !current_attr.save - && (gfc_option.allow_std & GFC_STD_F2008) != 0) + /* Since Fortran 2008, variables declared in a MODULE or PROGRAM + implicitly have the SAVE attribute. */ + if ((gfc_current_state () == COMP_MODULE + || gfc_current_state () == COMP_PROGRAM) + && !current_attr.save && (gfc_option.allow_std & GFC_STD_F2008) != 0) current_attr.save = SAVE_IMPLICIT; colon_seen = 1; This also removes the automatic allocation of both variables in the test case in comment 0. Therefore it has the same testsuite failures as the patch in comment 1 (possibly more?).