public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/101814] New: Initialization of local variables broken in presence of SAVE
@ 2021-08-07 18:28 anlauf at gcc dot gnu.org
2021-08-07 18:39 ` [Bug fortran/101814] " anlauf at gcc dot gnu.org
0 siblings, 1 reply; 2+ messages in thread
From: anlauf at gcc dot gnu.org @ 2021-08-07 18:28 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101814
Bug ID: 101814
Summary: Initialization of local variables broken in presence
of SAVE
Product: gcc
Version: 12.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: fortran
Assignee: unassigned at gcc dot gnu.org
Reporter: anlauf at gcc dot gnu.org
Target Milestone: ---
While working on PR68568, I realized that using initialization of local
variables using -finit-local-zero, -finit-integer=nnn etc. rejects
valid code in the presence of a SAVE statement.
% cat zz1.f90
subroutine s1(n)
integer, intent(in) :: n
character(len=n) :: x
save
x = 'a'
end
% gfc-12 -c zz1.f90 -finit-local-zero
zz1.f90:1:13:
1 | subroutine s1(n)
| 1
Error: non-constant initialization expression at (1)
% cat zz2.f90
subroutine s2(n)
integer, intent(in) :: n
integer :: y(n)
save
y = 1
end
% gfc-12 -c zz2.f90 -finit-local-zero
zz2.f90:3:29:
3 | integer :: y(n)
| 1
Error: Automatic array 'y' at (1) cannot have an initializer
% cat zz3.f90
subroutine s1(n)
integer, intent(in) :: n
character(len=n) :: x(n)
save
x = 'a'
end
% gfc-12 -c zz3.f90 -finit-local-zero
zz3.f90:3:29:
3 | character(len=n) :: x(n)
| 1
Error: Automatic array 'x' at (1) cannot have an initializer
Commenting out the SAVE statements or removing -finit* allows the code
to compile.
Both error messages are bogus, and the code is valid:
F2018: 8.6.14 SAVE statement
(1) (...) A SAVE statement without a saved entity list is treated as though
it contained the names of all allowed items in the same scoping unit.
As automatic objects are not allowed items they should be ignored by the SAVE
and its presence should not make any difference.
^ permalink raw reply [flat|nested] 2+ messages in thread
* [Bug fortran/101814] Initialization of local variables broken in presence of SAVE
2021-08-07 18:28 [Bug fortran/101814] New: Initialization of local variables broken in presence of SAVE anlauf at gcc dot gnu.org
@ 2021-08-07 18:39 ` anlauf at gcc dot gnu.org
0 siblings, 0 replies; 2+ messages in thread
From: anlauf at gcc dot gnu.org @ 2021-08-07 18:39 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101814
anlauf at gcc dot gnu.org changed:
What |Removed |Added
----------------------------------------------------------------------------
Last reconfirmed| |2021-08-07
Ever confirmed|0 |1
See Also| |https://gcc.gnu.org/bugzill
| |a/show_bug.cgi?id=59537
Priority|P3 |P4
Keywords| |rejects-valid
Status|UNCONFIRMED |NEW
--- Comment #1 from anlauf at gcc dot gnu.org ---
See also the related PR59537.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-08-07 18:39 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-07 18:28 [Bug fortran/101814] New: Initialization of local variables broken in presence of SAVE anlauf at gcc dot gnu.org
2021-08-07 18:39 ` [Bug fortran/101814] " anlauf at gcc dot gnu.org
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).