This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug fortran/25395] New: equivalence to common block array broken


The following code shows the problem:
      program test

      common /abc/ mwkx(80)
      dimension    listpr(20),lisbit(10),lispat(8)

*     This is badly compiled
*     ======================
      equivalence (listpr(10),lisbit(1),mwkx(10))
     +,           (listpr(10),lispat(1))

      do i = 1,20
        listpr(i) = 0
      enddo
      do i = 1,10
        lisbit(i) = i
      enddo
      do j = 3,4
        lisbit(j) = 0
      enddo
      print *, '======================================================'
      print *, 'wrong result:'
      print '(20i4)', listpr
      call sub1
      call sub2
      stop
      end

      subroutine sub1

      common /abc/ mwkx(80)
      dimension    listpr(20),lisbit(10),lispat(8)

*     This is a workaround
*     ====================
      equivalence (listpr(10),lisbit(1)), (listpr(10),mwkx(10))
     +,           (listpr(10),lispat(1))

      do i = 1,20
        listpr(i) = 0
      enddo
      do i = 1,10
        lisbit(i) = i
      enddo
      do j = 3,4
        lisbit(j) = 0
      enddo
      print *, '======================================================'
      print *, 'correct result:'
      print '(20i4)', listpr
      end

      subroutine sub2

*     This gives correct results
*     ==========================
      dimension    mwkx(80)
      dimension    listpr(20),lisbit(10),lispat(8)
      equivalence (listpr(10),lisbit(1),mwkx(10))
     +,           (listpr(10),lispat(1))

      do i = 1,20
        listpr(i) = 0
      enddo
      do i = 1,10
        lisbit(i) = i
      enddo
      do j = 3,4
        lisbit(j) = 0
      enddo
      print *, '======================================================'
      print *, 'correct result (common replaced by dimension):'
      print '(20i4)', listpr
      end
This yields the following output:

 ======================================================
 wrong result:
   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0  
0
 ======================================================
 correct result:
   0   0   0   0   0   0   0   0   0   1   2   0   0   5   6   7   8   9  10  
0
 ======================================================
 correct result (common replaced by dimension):
   0   0   0   0   0   0   0   0   0   1   2   0   0   5   6   7   8   9  10  
0


-- 
           Summary: equivalence to common block array broken
           Product: gcc
           Version: 4.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: harald dot vogt at desy dot de


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]