From: fredex AT fcshome DOT stoneham DOT ma DOT us Message-Id: <199606112244.SAA03166@fcshome.stoneham.ma.us> Subject: Re: GCC fstrength-reduce bug To: junaid AT aurora DOT cc DOT monash DOT edu DOT au (Mr A. Walker) Date: Tue, 11 Jun 1996 18:44:57 -0400 (EDT) Cc: djgpp AT delorie DOT com In-Reply-To: <4piu9t$4vp@harbinger.cc.monash.edu.au> from "Mr A. Walker" at Jun 11, 96 04:56:29 am Content-Type: text Content-Length: 3117 Thinking furiously, Mr A. Walker wrote: > > I remember reading that the current GCC v2.7.2 is affliced > with a bug that occurs when strength reduction optimisation is used. > There was a short test program to see if the bug was present. Has anyone > go this program. Also is gcc v2.6.3 got this bug? Can v2.6.3 be > safely used instead of v2.7.2 with the current DJGPP V2 distribution? It purportedly exists in 2.5.8, also, and I understand it has not been fixed since, so there apparently are a whole rash of GCC versions with this bug. Below is a short program I just got the other day from one of the linux groups that claims to diagnose the problem: /* sr_bug.c * * This program tests for a gcc bug. * To compile this test program: gcc -O2 sr_bug.c * * Sometimes gcc for Intel CPUs generates bad code at optimization * level 2. The bad code is 'almost right' and stay hidden inside * a program that seems to work - including the Linux kernel. * The bug is very old and has been reported. As of 19-Dec-95, * the bug has not been fixed. * * If you change this code you should test it, because even a * tiny change will hide this elusive bug. If you think you * fixed the bug, please run the original test just to make * sure. You can find the original test below, after the #if 0. * I wrote this version of the test to be user-friendly, and * it may not be as solid as the original. * * Some people who know more than I do: * davis AT space DOT mit DOT edu (John E. Davis) * anlauf AT crunch DOT ikp DOT physik DOT th-darmstadt DOT de (Harald Anlauf) * craigs AT iii2 DOT iii DOT net (Craig Shrimpton) * * User-friendly version by Albert Cahalan * */ #include int gcc_sr_bug(void){ static int Array[3]; /* must be static (or global) */ unsigned int B = 3; /* must be unsigned 32-bit */ int i; for(i=0; i int A[3]; unsigned int B = 3; void printit(void){ int i; for(i = 0; i < B; i++) fprintf(stdout, "A[%d] = %d\n", i, A[i]); } int main(){ int i; for(i = 0; i < B; i++) A[i] = i - 3; printit(); return 0; } #endif -- ------------------------------------------------------------------------------- .---- Fred Smith / Office: fred AT computrition DOT com ( /__ ,__. __ __ / __ : / 508-663-2524 / / / /__) / / /__) .+' Home: fredex AT fcshome DOT stoneham DOT ma DOT us / / (__ (___ (__(_ (___ / :__ 617-438-5471 -------------------------------- Jude 1:24,25 ---------------------------------