public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/35756]  New: incorrect WHERE for functions in ELSEWHERE and overlaps
@ 2008-03-29 15:38 dick dot hendrickson at gmail dot com
  2008-03-29 15:52 ` [Bug fortran/35756] " burnus at gcc dot gnu dot org
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: dick dot hendrickson at gmail dot com @ 2008-03-29 15:38 UTC (permalink / raw)
  To: gcc-bugs

The following program computes the wrong values for the even
(elsewhere branch) of the left hand array.  It looks like the
function R_MY_MIN_I is evaluated before the store in the WHERE
branch happens.

The same thing happens if the R_M* functions are external 
rather than contained.

Dick Hendrickson

      program RA1028

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

      INTEGER  ILA(10)
      LOGICAL  LDA(10)

      ILA = (/ (I, i=1,10) /)
      LDA = (/ (i/2*2 .ne. I, i=1,10) /)

      WHERE(LDA)
        ILA = R_MY_MAX_I(ILA)
      ELSEWHERE
        ILA = R_MY_MIN_I(ILA)
      ENDWHERE

      print *, 10,2,10,2, '  etc'        !expected
      print *, ila

      CONTAINS

      INTEGER FUNCTION R_MY_MAX_I(A)
      INTEGER  ::  A(:)
      R_MY_MAX_I = MAXVAL(A)
      END FUNCTION R_MY_MAX_I     !internal procedure

      INTEGER FUNCTION R_MY_MIN_I(A)
      INTEGER  ::  A(:)
      R_MY_MIN_I = MINVAL(A)
      END FUNCTION R_MY_MIN_I     !internal procedure

      END



C:\g_experiments\gfortran>gfortran ra1028.f

C:\g_experiments\gfortran>a
          10           2          10           2   etc
          10           1          10           1          10           1
  10           1          10           1


-- 
           Summary: incorrect WHERE for functions in ELSEWHERE and overlaps
           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=35756


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

end of thread, other threads:[~2008-05-17  7:17 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-03-29 15:38 [Bug fortran/35756] New: incorrect WHERE for functions in ELSEWHERE and overlaps dick dot hendrickson at gmail dot com
2008-03-29 15:52 ` [Bug fortran/35756] " burnus at gcc dot gnu dot org
2008-03-31 20:37 ` pault at gcc dot gnu dot org
2008-05-16 21:13 ` pault at gcc dot gnu dot org
2008-05-17  7:12 ` pault at gcc dot gnu dot org
2008-05-17  7:17 ` pault 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).