[Bug fortran/35756] New: incorrect WHERE for functions in ELSEWHERE and overlaps
dick dot hendrickson at gmail dot com
gcc-bugzilla@gcc.gnu.org
Sat Mar 29 15:38:00 GMT 2008
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
More information about the Gcc-bugs
mailing list