http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58433
--- Comment #3 from janus at gcc dot gnu.org --- (In reply to Valery Weber from comment #2) > But the std says: > > > **** > 4.5.6.3 When finalization occurs > ... > 2 A nonpointer, nonallocatable object that is not a dummy argument or > function result is finalized immediately before it would become undefined > due to execution of a RETURN or END statement (16.6.6, item (3)). That's right. However, 16.6.6 (3) says: (3) When execution of an instance of a subprogram completes, (a) its unsaved local variables become undefined So, firstly, this only talks about 'subprograms' and, secondly, about *unsaved* local variables. At least in F08, variables in the main program implicitly get the SAVE attribute. More importantly, note that 4.5.6.4 explicitly states that entities are not finalized on an end-program-stmt! We had quite some discussions about this already last year, both on c.l.f. (see https://groups.google.com/forum/?fromgroups=#!topic/comp.lang.fortran/mhQLZOmVQ8Q) and the gfortran mailing list (see e.g. http://gcc.gnu.org/ml/fortran/2012-10/msg00136.html and other posts in this thread).