From: Steve Kargl <sgk@troutmask.apl.washington.edu>
To: Tobias Burnus <burnus@net-b.de>
Cc: Fritz Reese <fritzoreese@gmail.com>,
fortran@gcc.gnu.org, gcc-patches@gcc.gnu.org
Subject: Re: [PATCH, Fortran] -fno-automatic with -finit-local prevents initialization of automatics in recursive functions
Date: Sun, 31 Aug 2014 22:43:00 -0000 [thread overview]
Message-ID: <20140831224336.GA3799@troutmask.apl.washington.edu> (raw)
In-Reply-To: <5403A197.3020400@net-b.de>
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
prev parent reply other threads:[~2014-08-31 22:43 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <CAE4aFAkSNjGYmpxUZtM8wSDYKvHaBxkpq2hX6sq8aqWfKndT+w@mail.gmail.com>
2014-08-29 20:13 ` Fritz Reese
2014-08-31 22:28 ` Tobias Burnus
2014-08-31 22:43 ` Steve Kargl [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20140831224336.GA3799@troutmask.apl.washington.edu \
--to=sgk@troutmask.apl.washington.edu \
--cc=burnus@net-b.de \
--cc=fortran@gcc.gnu.org \
--cc=fritzoreese@gmail.com \
--cc=gcc-patches@gcc.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).