[PATCH, Fortran] -fno-automatic with -finit-local prevents initialization of automatics in recursive functions

Tobias Burnus burnus@net-b.de
Sun Aug 31 22:28:00 GMT 2014


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):

Thanks for the patch. I think it qualifies as obvious. But note for 
potential future contributions that for nontrivial contributions a 
copyright assignment with the FSF is required: 
https://gcc.gnu.org/contribute.html

(Tiny nit: 8 spaces are replaced by a tab.)

I initially thought that one had to be more careful because of BLOCK, 
but the RECURSIVE is passed on those namespaces, hence, the patch works 
fine. I have extended the test case to cover that part as well.

I have now committed the attached version of the patch to the trunk (GCC 
5) as Rev. 214771.

Tobias

(Side remark: I think it is bad style to rely on -finit-local with new 
code - and RECURSIVE is new since Fortran 90) code.)

> 2014-08-29  Fritz Reese  <Reese-Fritz@zai.com>
>
>      * resolve.c (apply_default_init_local): Don't treat variables in
>      RECURSIVE units as saved.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: committed.diff
Type: text/x-patch
Size: 3692 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20140831/22de9a30/attachment.bin>


More information about the Gcc-patches mailing list