Mail Archives: djgpp/1998/02/02/12:15:21
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.
- Raw text -