From: Robert Ruehlmann Newsgroups: comp.os.msdos.djgpp Subject: Compiler optimization bug Date: 12 Dec 1999 14:17:38 GMT Organization: The Pits of Angband Lines: 28 Message-ID: <830aq2$68s$1@news-int.gatech.edu> NNTP-Posting-Host: r38h184.res.gatech.edu X-Trace: news-int.gatech.edu 945008258 6428 128.61.38.184 (12 Dec 1999 14:17:38 GMT) X-Complaints-To: usenet AT news DOT gatech DOT edu NNTP-Posting-Date: 12 Dec 1999 14:17:38 GMT User-Agent: tin/pre-1.4-19990517 ("Psychonaut") (UNIX) (Linux/2.2.5 (i686)) To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com I think I've found a bug in the DJGPP compiler (gcc 2.95.2). When optimized with -O2 the following small sample program goes into an infinite loop. Debugging with gdb shows strange behaviour like modifications of the 'size' variable. <-- cut here --> static void bug(int size, int tries) { int i; int num = 0; while (num < size) { for (i = 1; i < tries; i++) num++; } } int main() { bug(5, 10); return 0; } <-- cut here --> -- Robert Ruehlmann ( rr9 AT angband DOT org ) "Thangorodrim - The Angband Page" : http://thangorodrim.angband.org/ Visit the #angband chat channel at Othernet (irc.othernet.org).