------- Comment #9 from burnus at gcc dot gnu dot org 2009-06-18 15:17 ------- (In reply to comment #7) > I'm still convinced that this is a problem of the compiler, since it works > with the > NAG and Intel compilers.
Well, compilers can have all bugs - and not all invalid programs can be diagnosed as such by a compiler. In any case, I believe gfortran has a bug (cf. comment 5 and comment 8). (In reply to comment #8) > Regarding the big program: [...] I think the big program is valid (at least with this regard) as the following applies. "If the dummy argument has the TARGET attribute, does not have the VALUE attribute, and is either a scalar or an assumed-shape array, and the corresponding actual argument has the TARGET attribute but is not an array section with a vector subscript then (1) Any pointers associated with the actual argument become associated with the corresponding dummy argument on invocation of the procedure and (2) When execution of the procedure completes, any pointers that do not become undefined (16.4.2.1.3) and are associated with the dummy argument remain associated with the actual argument." [F2003, 12.4.1.2 Actual arguments associated with dummy data objects] And in "16.4.2.1.3 Events that cause the association status of pointers to become undefined". Relevant would be for instance: "(4) Execution of a RETURN or END statement causes the pointers target to become undefined (item (3) of 16.5.6)," which is never the case for the PROGRAM; additionally, the SAVE preserves it even longer [(3) in 16.5.6]: "Variables become undefined as follows: [...] (3) When execution of an instance of a subprogram completes, (a) its unsaved local variables become undefined," -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40440