On Mon, Sep 01, 2014 at 12:28:39AM +0200, Tobias Burnus wrote:
> Fritz Reese wrote:
> > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=62309
> >
> > It seems with gcc-4.8.3 -fno-automatic prevents initializers from
> > being applied to automatic variables.
> [...]
> > According to gfortran's manual page, -fno-automatic should "Treat each
> > program unit (except those marked as RECURSIVE) as if the "SAVE"
> > statement were specified for every local variable [...]". As far as I
> > can tell, -finit-local-zero should still initialize automatic
> > variables in RECURSIVE functions.
> >
> > I believe this is a simple fix; to actually follow the specification
> > set forth in the man page, don't treat symbols in a RECURSIVE
> > namespace as if they are saved in resolve.c
> > (apply_default_init_local):
> 

(large snip)

> +implicit none
> +  integer f, x
> +  integer a ! should be SAVEd
> +  a = a + x ! should increment by y every time

a is undefined on the RHS.  Relying a compiler option to
make the code conforming is rather dubious.  I'd rather
see an error here; even if the user uses a option because
the user is too lazy to write conforming code.

> +  f = a
> +  return
> +endfunction
> +
> +function f2 (x)
> +implicit none
> +  integer f2, x
> +  block
> +   named: block
> +    block
> +    integer a ! should be SAVEd
> +    a = a + x ! should increment by y every time
> +    f2 = a

a is undefined on the RHS and this should elicit an error.

PS: the comment is wrong as there is no y.

> +    end block
> +   end block named
> +  end block
> +  return
> +endfunction
> +
> +recursive function g (x)
> +implicit none
> +  integer g, x
> +  integer b ! should be automatic
> +  b = b + x ! should be set to y every time

b is undefined on the RHS and this should elicit an error.

PS: the comment is wrong as there is no y.

The -finit-* option were implemented for compatibility with
g77 and to allow the compilation of dusty deck code.  New
code should be written to conform to the standard.

-- 
Steve

Reply via email to