------- Comment #3 from tkoenig at gcc dot gnu dot org 2008-04-22 18:57 ------- This one is seriously strange.
It depends on the mask argument being a compile-time constant. Apparently, simplification goes down a wrong path somewhere. Looking at the $ cat try.f90 program GA4076 ! fails on Windows XP ! gcc version 4.4.0 20080312 (experimental) [trunk revision 133139] REAL DDA(100) dda = (/(J1,J1=1,100)/) IDS = MAXLOC(DDA,1, (/(J1,J1=1,100)/) > 50) print *, 2, ids, ids.eq.100 !expect 100 END $ gfortran -fdump-tree-original try.f90 $ ./a.out 2 101 F The loop generated for maxloc lacks any reference to the mask: pos.2 = 0; { integer(kind=4) S.6; S.6 = 1; while (1) { if (S.6 > 100) goto L.1; if (A.5[S.6 + -1]) { offset.3 = 1; if (dda[S.6 + -1] > limit.4 || pos.2 == 0 && dda[S.6 + -1] == limit.4) { limit.4 = dda[S.6 + -1]; pos.2 = S.6 + offset.3; } } S.6 = S.6 + 1; } L.1:; } ids = pos.2; } The following works: $ cat try2.f90 program GA4076 REAL DDA(100) dda = (/(J1,J1=1,100)/) IDS = MAXLOC(DDA,1, dda > 50) print *, 2, ids, ids.eq.100 !expect 100 END $ gfortran try2.f90 $ ./a.out 2 100 T Paul, can you maybe shed any light on this? -- tkoenig at gcc dot gnu dot org changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |pault at gcc dot gnu dot org http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35994