This is the mail archive of the
fortran@gcc.gnu.org
mailing list for the GNU Fortran project.
Re: -fno-automatic option (PR 20592)
On Wednesday 31 August 2005 21:03, FX Coudert wrote:
> > This option should not apply to RECURSIVE functions. It's ok for
> > non-recursive functions because it's just making undefined behaviour
> > implementation defined. However for RECURSIVE functions it breaks legal
> > programs.
>
> We'll have to think about that. On one hand, this option is mostly used
> for compatibility reasons by people using old code, with no recursive
> functions in it. So, do you think we should silently ignore the option
> for recursive functions, or do we need to error out ("-fno-automatic
> option cannot be used with recursive functions")?
My understanding was that this option was intended for nonstandard legacy
code. This code is unlikely to be using f95 features. I find it hard to
believe any new f95 code will want the broken semantics.
IMO recursive functions and variables with the ALLOCATABLE attribute should
silently ignore -fno-automatic. If we do decide we want it to change standard
semantics, -fsave-all may be a more appropriate name.
Making undefined behaviour defined is ok.
Deliberately breaking well defined legal code is a totally different matter.
Either way these interactions should be clearly documented.
> >>+Treat each program unit as if the @code{SAVE} statement was specified
> >> for +every local variable and array referenced in it. Does not affect
> >> common +blocks. (Some Fortran compilers provide this option under the
> >> name +@option{-static}.)
> >
> > This isn't entirely accurate. It's the equivalent of adding a single
> > "save" statement with no saved-entity-list. This is different because it
> > only applies to "all allowed items in the same scoping unit" (Section
> > 5.2.4). In particular it does not apply to automatic (aka variable size)
> > objects. eg.
>
> I was merely copy-pasting the g77 info doc. I'll try to come up with
> something better, along the lines you mention.
>
> > subroutine foo(n)
> > integer n
> > integer, dimension(n) :: a
> > save
> > a = 0;
> > end subroutine
> >
> > "a" will not be given the SAVE attribute.
>
> Yes, indeed. I don't know if your comment was only about the doc or the
> patch itself, but just in case: the -fno-automatic option does add the
> save attribute only to non-automatic variables (in fact, it uses the
> same code as for a single "save" statement with no saved-entity-list.
My comment was about the documentation. Given my comments above, my suggested
working is also incorrect.
Paul