gfortran(gcc-4.0.0) silently changes the value of variables in equivalence 
statements.  The following code prints the value "0" and not "1": 
 
      implicit none 
      integer O 
      DIMENSION O(300000) 
      COMMON /IBM/O 
      integer b,e,r,s,v,u,w,x,c 
      EQUIVALENCE(O(1),B),(O(2),E),(O(3),R),(O(4),S),(O(5),V),(O(6),U), 
     *(O(7),W),(O(8),X),(C,O(12)) 
 
      O(9)=1 
 
      CALL MYSUB 
      END 
 
      subroutine MYSUB 
      implicit none 
      integer O 
      DIMENSION O(300000) 
      COMMON /IBM/O 
      integer b,e,r,s,v,u,w,x,c 
      EQUIVALENCE(O(1),B),(O(2),E),(O(3),R),(O(4),S),(O(5),V),(O(6),U), 
     *(O(7),W),(O(8),X),(C,O(12)) 
      WRITE(6,*) "IN MYSUB: O(9)= ", O(9) 
      RETURN 
      END 
 
 
As always, thank you.  You folks do excellent work. 
 
Sincerely, 
 Mike Albert

-- 
           Summary: gfortran silently changes values in equilvanence'd
                    variables
           Product: gcc
           Version: 4.0.0
            Status: UNCONFIRMED
          Severity: critical
          Priority: P1
         Component: fortran
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: albertm at uphs dot upenn dot edu
                CC: gcc-bugs at gcc dot gnu dot org
 GCC build triplet: x86_64-unknown-linux-gnu (AMD)
  GCC host triplet: x86_64-unknown-linux-gnu (AMD)
GCC target triplet: x86_64-unknown-linux-gnu (AMD)


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=22304

Reply via email to