public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/25395]  New: equivalence to common block array broken
@ 2005-12-13 17:36 harald dot vogt at desy dot de
  2006-02-19 20:15 ` [Bug fortran/25395] " tobi at gcc dot gnu dot org
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: harald dot vogt at desy dot de @ 2005-12-13 17:36 UTC (permalink / raw)
  To: gcc-bugs

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


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2006-03-07  2:25 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-12-13 17:36 [Bug fortran/25395] New: equivalence to common block array broken harald dot vogt at desy dot de
2006-02-19 20:15 ` [Bug fortran/25395] " tobi at gcc dot gnu dot org
2006-02-20 15:25 ` paul dot richard dot thomas at cea dot fr
2006-02-24 10:51 ` pault at gcc dot gnu dot org
2006-02-24 10:53 ` pault at gcc dot gnu dot org
2006-02-27  3:44 ` pinskia at gcc dot gnu dot org
2006-03-07  0:07 ` pault at gcc dot gnu dot org
2006-03-07  2:25 ` pinskia at gcc dot gnu dot org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).