The following program computes the wrong result for a WHERE where
different sections of the same array are in both the WHERE and
ELSEWHERE section.  It's "as if" the ELSEWHERE block were
ignored.

Dick Hendrickson

      program RG0023
! fails on Windows XP
! gcc version 4.4.0 20080312 (experimental) [trunk revision 133139]


      integer UDA1L(6)
      integer ::  UDA1R(6), expected(6) = (/2,0,5,0,3,0/)
      LOGICAL LDA(5)

      UDA1L(1:6) = 0
      uda1r = (/1,2,3,4,5,6/)
      lda = (/ (i/2*2 .ne. I, i=1,5) /)

      WHERE (LDA)                !          expected
        UDA1L(1:5) = UDA1R(2:6)  !  uda1l = 2,0,4,0,6,0
      ELSEWHERE
        UDA1L(2:6) = UDA1R(6:2:-1) !uda1l = 2,0,5,0,3,0
      ENDWHERE

      print *, 'expected = ',expected
      print *, 'computed = ', uda1l

      END

gfortran:gfortran rg0023.f

gfortran:a
 expected =            2           0           5           0           3      
0
 computed =            2           0           4           0           6      
0


-- 
           Summary: WHERE with overlap with ELSEWHERE error
           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=35759

Reply via email to