delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/02/01/17:13:19

From: SOLYOM Andras <solyom AT eik DOT bme DOT hu>
Message-Id: <199802012210.XAA01335@goliat.eik.bme.hu>
Subject: Compiler error! (and something about Virtual memory)
To: djgpp AT delorie DOT com
Date: Sun, 1 Feb 1998 23:10:41 +0100 (MET)
MIME-Version: 1.0

First the latter: I have sent a question regarding virtual memory when one of 
my program crashed. I tried everything I was proposed. Then when nothing have 
worked I have rewritten the code to first determine the total size I needed 
then to allocate memory in 4096 bytes blocks till that amount in a second run. 
The program is much slower, but works. 

In this same program  I have discovered a compiler error with -O3. 

I have this little code in my program 

.... 
        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. 

So you have been warned... 

                                                                                            Andras 

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019