Bug 71523 - Static variables given automatic initializers with -finit-* and -fmax-stack-var-size
Summary: Static variables given automatic initializers with -finit-* and -fmax-stack-v...
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: fortran (show other bugs)
Version: 7.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-06-13 16:28 UTC by Fritz Reese
Modified: 2016-07-17 22:11 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2016-07-15 00:00:00


Attachments
Patch for pr71523 (1.69 KB, patch)
2016-06-13 16:47 UTC, Fritz Reese
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Fritz Reese 2016-06-13 16:28:54 UTC
This bug is similar to pr41860. When a variable becomes static due to being larger than -fmax-stack-var-size, the variable is still given an automatic initializer on entry to its namespace by the -finit-* flags (-finit-integer, -finit-local-zero, etc...)

This is probably an oversight due to the fact that the initializers are generated at resolution time in resolve.c, but the size of the variable is not known until translation time (in trans-decl.c).

S.A. the thread at https://gcc.gnu.org/ml/fortran/2016-06/msg00023.html
Comment 1 Fritz Reese 2016-06-13 16:47:21 UTC
Created attachment 38697 [details]
Patch for pr71523

Patch submitted, see https://gcc.gnu.org/ml/fortran/2016-06/msg00032.html
Comment 2 Dominique d'Humieres 2016-07-15 10:15:42 UTC
> Patch submitted, see https://gcc.gnu.org/ml/fortran/2016-06/msg00032.html
Comment 3 Dominique d'Humieres 2016-07-15 10:17:15 UTC
> Patch submitted, see https://gcc.gnu.org/ml/fortran/2016-06/msg00032.html

Hit return too soon!-(

The patch works as advertised. I think you should ping the mailing lists and assign the PR to yourself.
Comment 4 Jerry DeLisle 2016-07-17 20:14:13 UTC
Author: jvdelisle
Date: Sun Jul 17 20:13:41 2016
New Revision: 238420

URL: https://gcc.gnu.org/viewcvs?rev=238420&root=gcc&view=rev
Log:
2016-07-17  Fritz Reese  <fritzoreese@gmail.com>

	PR fortran/71523
	* trans-decl.c (gfc_finish_var_decl): Replace automatic initializer with
	a static one.

	* gfortran.dg/pr71523_1.f90: New test.
	* gfortran.dg/pr71523_2.f90: New test.

Added:
    trunk/gcc/testsuite/gfortran.dg/pr71523_1.f90
    trunk/gcc/testsuite/gfortran.dg/pr71523_2.f90
Modified:
    trunk/gcc/fortran/ChangeLog
    trunk/gcc/fortran/trans-decl.c
    trunk/gcc/testsuite/ChangeLog
Comment 5 Jerry DeLisle 2016-07-17 22:11:32 UTC
Fixed, Closing