Hi, I check tha attached bug.c on each gcc package release. It is still failing, and also does with a recent gcc-3 snapshot. Anybody knows if gcc people is aware of this ? Bug: x86 low level optimizer is broken for strength-reducion. Attached bug.c gives bad results when compiled with 'gcc -O2' and ok with 'gcc -O2 -fno-strength-reduce'. Its s86 specific because it does not show in IRIX nor in Solaris. -- J.A. Magallon # Let the source mailto:[EMAIL PROTECTED] # be with you, Luke... Linux werewolf 2.4.3-ac3 #1 SMP Thu Apr 5 00:28:45 CEST 2001 i686
#include <stdio.h> #define SMALL_N 2 #define NUM_ELEM 4 int main(void) { int listElem[NUM_ELEM]={30,2,10,5}; int listSmall[SMALL_N]; int i, j; int posGreatest=-1, greatest=-1; for (i=0; i<SMALL_N; i++) { listSmall[i] = listElem[i]; if (listElem[i] > greatest) { posGreatest = i; greatest = listElem[i]; } } for (i=SMALL_N; i<NUM_ELEM; i++) { if (listElem[i] < greatest) { listSmall[posGreatest] = listElem[i]; posGreatest = 0; greatest = listSmall[0]; for (j=1; j<SMALL_N; j++) { if (listSmall[j] > greatest) { posGreatest = j; greatest = listSmall[j]; } } //printf("%d\n", posGreatest); } } printf("Correct output: 5 2\n"); printf("GCC output: "); for (i=0; i<SMALL_N; i++) printf(" %.1d", listSmall[i]); printf("\n"); return (1); }