http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53597
Bug #: 53597 Summary: [4.6/4.7/4.8 Regression] F95/F2003 constraint no longer triggers: un-SAVED default-initialized module variable Classification: Unclassified Product: gcc Version: 4.8.0 Status: UNCONFIRMED Keywords: accepts-invalid, diagnostic Severity: normal Priority: P3 Component: fortran AssignedTo: unassig...@gcc.gnu.org ReportedBy: bur...@gcc.gnu.org Based on the discussion at https://groups.google.com/forum/?fromgroups#!topic/comp.lang.fortran/7QfDs7wtKVY The following check in resolve.c does not trigger as attr.save == SAVE_IMPLICIT: if (!(sym->value || no_init_flag) && sym->ns->proc_name && sym->ns->proc_name->attr.flavor == FL_MODULE && !sym->ns->save_all && !sym->attr.save && !sym->attr.pointer && !sym->attr.allocatable && gfc_has_default_initializer (sym->ts.u.derived) && gfc_notify_std (GFC_STD_F2008, "Fortran 2008: Implied SAVE for " "module variable '%s' at %L, needed due to " "the default initialization", sym->name, when compiling the following program with -std=f95 or -std=f2003: MODULE somemodule IMPLICIT NONE TYPE sometype INTEGER :: i DOUBLE PRECISION, POINTER, DIMENSION(:,:) :: coef => NULL() END TYPE sometype TYPE(sometype) :: somevariable END MODULE somemodule Possible patches: a) Check for (sym->attr.save == SAVE_EXPLICIT || sym->value) b) Use the patch below: --- a/gcc/fortran/decl.c +++ b/gcc/fortran/decl.c @@ -3810,8 +3810,9 @@ match_attr_spec (void) } } - /* Module variables implicitly have the SAVE attribute. */ - if (gfc_current_state () == COMP_MODULE && !current_attr.save) + /* 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) current_attr.save = SAVE_IMPLICIT; colon_seen = 1;