------- Additional Comments From Thomas dot Koenig at online dot de 2004-11-22
12:29 -------
(In reply to comment #5)
> Hmmm, I do not get this on my powerpc-unknown-linux-gnu:
I am also not getting this with -O on ia64-unknown-linux-gnu . Apparently,
the array assignment in bar is commented away, and the stack isn't clobbered.
Here is another testcase, which causes the bug to be exposed (for me,
at least):
$ gfortran -v
Reading specs from /home/zfkts/lib/gcc/ia64-unknown-linux-gnu/4.0.0/specs
Configured with: ../gcc-4.0-20041107/configure --prefix=/home/zfkts
--enable-languages=c,c++,f95
Thread model: posix
gcc version 4.0.0 20041107 (experimental)
$ cat foobar.f90
program main
call foo
call bar(i)
call foo
end program main
subroutine foo
integer i,g,h
data i/0/
equivalence (g,h)
save g
if (i == 0) then
i = 1
h = 12345
end if
print *,h
end subroutine foo
subroutine bar(n)
integer a(10)
a = (/ (i, i=1,10) /)
n = sum(a)
end subroutine bar
$ gfortran foobar.f90 && ./a.out
12345
55
$ gfortran -O foobar.f90 && ./a.out
12345
7
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=18518