public inbox for fortran@gcc.gnu.org
 help / color / mirror / Atom feed
* -fmax-stack-var-size with -finit-local-zero
@ 2016-06-09 18:01 Fritz Reese
  0 siblings, 0 replies; only message in thread
From: Fritz Reese @ 2016-06-09 18:01 UTC (permalink / raw)
  To: fortran

It looks like when -fautomatic and -finit-local-zero are set with
-fmax-stack-var-size=X, an automatic initializer is generated even for
variables larger than X which are given static storage, causing such
static variables to have their value re-initialized upon each entry to
their namespace.

As a counterexample, -finit-local-zero does not generate automatic
initializers for variables which become static due to -fno-automatic.

It seems to me the latter behavior should be preferred for both cases;
-finit-local-zero should not generate automatic initializers for
static variables regardless of why the variable decided to become
static.

I have a patch which unifies this behavior, such that variables which
are coerced into being static by -fmax-stack-var-size will not be
given automatic initializers on namespace entry by -finit-local-zero.
Before I submit it, I want to make sure I correctly understand the
intended behavior. My only hesitation comes from this section of
trans-decl.c (gfc_get_symbol_decl):

> if (TREE_STATIC (decl)
>      && !(sym->attr.use_assoc && !intrinsic_array_parameter)
>      && (sym->attr.save || sym->ns->proc_name->attr.is_main_program
>          || flag_max_stack_var_size == 0
>          || sym->attr.data || sym->ns->proc_name->attr.flavor == FL_MODULE)
>      && (flag_coarray != GFC_FCOARRAY_LIB
>          || !sym->attr.codimension || sym->attr.allocatable))
>    {
>      /* Add static initializer. For procedures, it is only needed if
>         SAVE is specified otherwise they need to be reinitialized
>         every time the procedure is entered. The TREE_STATIC is
>         in this case due to -fmax-stack-var-size=.  */
>       DECL_INITIAL (decl) = gfc_conv_initializer (sym->value, &sym->ts,
...

According to the comment here, even a variable that has become static
due to -fmax-stack-var-size should explicitly /not/ get a static
initializer, although maybe it refers only to FL_PROCEDUREs... This is
unclear to me.

Thoughts?

---
Fritz Reese

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2016-06-09 18:01 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-06-09 18:01 -fmax-stack-var-size with -finit-local-zero Fritz Reese

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