[Bug fortran/93263] New: -fno-automatic and RECURSIVE
gcc.bugzilla at he dot sk
gcc-bugzilla@gcc.gnu.org
Tue Jan 14 12:30:00 GMT 2020
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93263
Bug ID: 93263
Summary: -fno-automatic and RECURSIVE
Product: gcc
Version: 9.2.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: fortran
Assignee: unassigned at gcc dot gnu.org
Reporter: gcc.bugzilla at he dot sk
Target Milestone: ---
The combination of -fno-automatic and RECURSIVE does not seem to behave
correctly in gfortran 9.2.1.
The output of the following program depends on whether it is compiled with or
without -fno-automatic, while according to the manual it should not.
program main
implicit none
call check(2)
end
recursive subroutine check(n)
implicit none
integer n, a
a = 10
print*,"n=",n
if (n==1) then
a=a-1
print*,"assigning a=",a
else
a=a-2
print*,"assigning a=",a
call check(n-1)
endif
print*,"a=",a
end
Output without -fno-automatic:
n= 2
assigning a= 8
n= 1
assigning a= 9
a= 9
a= 8
Output with -fno-automatic:
n= 2
assigning a= 8
n= 1
assigning a= 9
a= 9
a= 9
It seems like with -fno-automatic the variable a is not AUTOMATIC while
according to the manual it should because the relevant program unit is marked
as RECURSIVE:
-fno-automatic
Treat each program unit (except those marked as RECURSIVE) as if the SAVE
statement were specified for every local variable and array referenced in it.
Does not affect common blocks. (Some Fortran compilers provide this option
under the name -static or -save.) The default, which is -fautomatic, uses the
stack for local variables smaller than the value given by -fmax-stack-var-size.
Use the option -frecursive to use no static memory.
https://gcc.gnu.org/onlinedocs/gfortran/Code-Gen-Options.html
Note that this behaviour changes with respect to previous versions of gfortran.
Thanks!
Tomas
More information about the Gcc-bugs
mailing list