The following program prints out the wrong results when an
array with vector valued subscript is used in an expression
as the FROM argument and also used as the TO argument.
The array case gives different results from a similar
scalar DO loop.

If a different array is used in the FROM argument, the array
results are the same as the scalar results.

I'd guess that you aren't recognizing
(ILA1(NFV3))
as an expression and copying it to a temp before invoking
MVBITS.

Dick Hendrickson


      program YA0017

! gcc version 4.4.0 20080312 (experimental) [trunk revision 133139] (GCC)

      INTEGER ILA1(10)
      INTEGER ILA2(10)
      INTEGER ICA3(10), nfv3(10)
      ILA1 = (/1,2,3,4,5,6,7,8,9,10/)
      ILA2 = (/1,2,3,4,5,6,7,8,9,10/)
      ica3 = (/1,2,3,4,5,6,7,8,9,10/)
      nfv3 = (/9,9,6,2,4,9,2,9,6,10/)

      DO J1 = 1,10
        CALL MVBITS(Ila1(NFV3(J1)),2,4,ILA2(J1), 3)
      ENDDO

      CALL MVBITS ((ILA1(NFV3)), 2, 4, ILA1, 3)       !fails

      print *, 'first test'
      DO J1 = 1,10
      IF (ILA1(J1) .NE. ILA2(J1))
     $ print *, 'j1 = ', j1, '  vvs = ', nfv3(j1),
     $ '  scalar =', ila2(j1), '  vector = ', ila1(j1)
      ENDDO


      ILA1 = (/1,2,3,4,5,6,7,8,9,10/)
      ILA2 = (/1,2,3,4,5,6,7,8,9,10/)
      ica3 = (/1,2,3,4,5,6,7,8,9,10/)
      nfv3 = (/9,9,6,2,4,9,2,9,6,10/)

      DO J1 = 1,10
        CALL MVBITS(Ica3(NFV3(J1)),2,4,ILA2(J1), 3)
      ENDDO

      CALL MVBITS ((Ica3(NFV3)), 2, 4, ILA1, 3)      !works

      print *, 'second test'
      DO J1 = 1,10
      IF (ILA1(J1) .NE. ILA2(J1))
     $ print *, 'j1 = ', j1, '  vvs = ', nfv3(j1),
     $ '  scalar =', ila2(j1), '  vector = ', ila1(j1)
      ENDDO
      END 


-------------------------------------------------------
results
C:\g_experiments\gfortran>gfortran ya0017.f
C:\g_experiments\gfortran>a
 first test
 j1 =            4   vvs =            2   scalar =           4   vector =
    36
 j1 =            5   vvs =            4   scalar =          13   vector =
    77
 j1 =            7   vvs =            2   scalar =           7   vector =
    39
 j1 =            9   vvs =            6   scalar =           9   vector =
    41
 second test


-- 
           Summary: wrong result for vector subscripted array expression in
                    MVBITS
           Product: gcc
           Version: 4.4.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: dick dot hendrickson at gmail dot com


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

Reply via email to