In message <36A5CEF3.EF699C09@magrathea.de>you write:
> OS: Linux (RedHat 5.2, Kernel 2.0.37pre3)
> egcs version: 1.1.1
>
> egcs was compiled with default options to configure, only
> the prefix was changed.
>
> The following program ist compiled correctly with -O,
> but egcs generates seriously incorrect code with -O2.
>
> Included:
> egcs-bug.c source of buggy program
> build.txt messages from compiler invocation
> egcs-bug.s annotated compiler output
>
> ---------- egcs-bug.c ----------
> #define N 20
> int x[N];
> extern void print(int);
>
> /* Print elements of x which are > 0 in descending order. */
> void buggy(void)
> {
> for (;;) {
> int i, mi, max;
> max = 0;
> for (i = 0; i < N; i++) {
> if (x[i] > max) {
> max = x[i];
> mi = i;
> }
> }
> if (max == 0)
> break;
> print(max);
> x[mi] = 0;
> }
> }
Thanks for the bug report. I've just installed a fix into the egcs source
tree to fix this bug. I've also installed a modified version of your
testcase into our regression testsuite.
jeff