[Patch, fortran] PR22304 - gfortran silently changes values in equivalenced

FX Coudert fxcoudert@gmail.com
Tue Aug 9 14:54:00 GMT 2005


[sorry if this message doesn't appear in the right thread, i didn't 
figure out how to let Thunderbird add a hand-made References header]

As the comment at the top of find_equivalence (trans-common.c, line 668) 
says: "Only checks for rules involving the first symbol in the 
equivalence set." So your patch indeed works in this case (which can be 
seen on the testcase you provided) but will fail in a very similar 
example, just adding another variable as the first element in the 
equivalence set:

$ cat a.f
       integer a(2), b, c, i
       COMMON /foo/ a
       EQUIVALENCE (i,a(1),b), (c,a(2))
       a(1)=101
       a(2)=102
       print *, a, b, c
       END
$ gfortran a.f  && ./a.out
          101         102 -1073743968         102

While the good behaviour is, of course:

$ ifort a.f && ./a.out
          101         102         101         102


So, I guess the choice will be between extending the find_equivalence 
function to go through the whole set, or design a new function for that 
particular task.

FX



More information about the Fortran mailing list