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

Asher Langton langton2@llnl.gov
Thu Aug 30 13:03:00 GMT 2007


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



More information about the Fortran mailing list