[Bug fortran/31711] rhs array is changed while assiging to same lhs array
burnus at gcc dot gnu dot org
gcc-bugzilla@gcc.gnu.org
Thu Apr 26 19:50:00 GMT 2007
------- Comment #5 from burnus at gcc dot gnu dot org 2007-04-26 20:50 -------
> This can be seen in the file (result.dat) generated by the program.
I missed that part. Reduced test:
program laplsolv
IMPLICIT NONE
integer, parameter :: n=10
double precision,dimension(0:n+1,0:n+1) :: T
double precision,dimension(n) :: tmp1,tmp2
integer :: i
T=0.0
T(0:n+1 , 0) = 1.0
T(0:n+1 , n+1) = 1.0
T(n+1 , 0:n+1) = 2.0
tmp1=T(1:n,0)
T(1:n,1)=(T(0:n-1,1)+T(1:n,1+1)+tmp1)
do i = 1, n
print '(20f4.1)', T(i,1)
end do
end program laplsolv
The "T(1:n,1)=(T(0:n-1,1)+T(1:n,1+1)+tmp1)" get wrongly translated as:
{
int8 S.4;
S.4 = 1;
while (1)
{
if (S.4 > 10) goto L.5;
t[S.4 + 12] = (t[S.4 + 11] + t[S.4 + 24]) + tmp1[S.4 + -1];
S.4 = S.4 + 1;
}
L.5:;
}
It should be something like:
for(int i = 1; i < 10; i++) {
t.1[i + 12 ] = (t[S.4 + 11] + t[S.4 + 24]) + tmp1[S.4 + -1];
for(int i = 1; i < 10; i++) {
t[i + 12] = t.1[i + 12]
That is: First the right-hand side needs to be evaluated before the lhs is
written.
--
burnus at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |burnus at gcc dot gnu dot
| |org
Status|UNCONFIRMED |NEW
Ever Confirmed|0 |1
Keywords| |wrong-code
Last reconfirmed|0000-00-00 00:00:00 |2007-04-26 20:50:32
date| |
Summary|Data parallel code gets |rhs array is changed while
|transformed to serial |assiging to same lhs array
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31711
More information about the Gcc-bugs
mailing list