This is the mail archive of the fortran@gcc.gnu.org mailing list for the GNU Fortran project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH, fortran] PR20441 -finit-local-zero


On 8/29/07, Tobias Burnus <burnus@net-b.de> wrote:
> I think you patch does not touch static variables (SAVE) thus they may
> not get default initialized.

Actually, it should initialize static variables, as well:

% cat foo.f90
program bar
  print *,"1:"
  call foo
  print *,"2:"
  call foo
end program bar

subroutine foo
  integer :: i1 = 101
  integer i2
  integer i3
  save i2

  print *,"Entry:", i1, i2, i3
  i1 = -1
  i2 = -2
  i3 = -3
  print *,"Exit:",i1,i2,i3
end subroutine foo

% gfc -finit-integer=1000 foo.f90
% ./a.out
 1:
 Entry:         101        1000        1000
 Exit:          -1          -2          -3
 2:
 Entry:          -1          -2        1000
 Exit:          -1          -2          -3



-Asher


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]