Date: Mon, 2 Feb 1998 19:08:08 +0200 (IST) From: Eli Zaretskii To: SOLYOM Andras cc: djgpp AT delorie DOT com Subject: Re: Compiler error! (and something about Virtual memory) In-Reply-To: <199802012210.XAA01335@goliat.eik.bme.hu> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Precedence: bulk On Sun, 1 Feb 1998, SOLYOM Andras wrote: > fseek(fCC, sizeof(TFILEHEADER) + > newNewsRecord.lKeywords[i]*sizeof(TKEYRECORD), 0); > fread(&kr, sizeof(TKEYRECORD), 1, fCC); > > while(kr.lParent) > { /* get ordinal of record in ll */ > ll = (kr.lParent - sizeof(TFILEHEADER)) / sizeof(TKEYRECORD) + 1; > if(ll >= lMin && ll < lMax) > SetBit(ll-lMin, l); > fseek(fCC, kr.lParent, 0); > fread(&kr, sizeof(TKEYRECORD), 1, fCC); > } > .... > > When compiled with -O3 the first fread() has never been executed: it > was missing from the code! Without -O3 it worked fine. I am using > gcc 2.7.2.1. I find this hard to believe. Please post the shortest source that can be compiled with -O3 and which exhibits this alleged bug. You might be missing something in the code generated by GCC. For example, it could be that the optimized code jumps into the loop, right before the call to `fread' near the end of the loop. This is semantically equivalent to your source, so it is a perfectly legal optimization.