https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71412
kargl at gcc dot gnu.org changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |kargl at gcc dot gnu.org --- Comment #1 from kargl at gcc dot gnu.org --- (In reply to relliott from comment #0) > Created attachment 38644 [details] > minimal skeleton code that illustrates the bug > > A problem exists in the way gfortran optimizes functions/subroutines when c > interoperability (and specifically the c_loc() intrinsic) are used. > I believe gfortran's behavior conforms to the standard. F2003 states When the execution of a procedure is terminated by execution of a RETURN or END statement, an allocatable variable that is a named local variable of the procedure retains its allocation and definition status if it has the SAVE attribute or is a function result variable or a subobject thereof; otherwise, it is deallocated. val is a local variable. val does not have the SAVE attribute.