public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* gcc 3.3 -03 produces bad code
@ 2003-04-17 20:10 Ronald Kukuck
  2003-04-17 20:25 ` Daniel Jacobowitz
  0 siblings, 1 reply; 8+ messages in thread
From: Ronald Kukuck @ 2003-04-17 20:10 UTC (permalink / raw)
  To: gcc

[-- Attachment #1: Type: text/plain, Size: 620 bytes --]

Hello,

I'm using:

gcc version 3.3 20030226 (prerelease) (SuSE Linux)

A large application (~25MB), which worked fine with the gcc included
in Suse 8.1, is now crashing in some modules if I compile it with "-O3".

I have tried to make the bug reproducible in a small file (test1.C).
To see it working OK use:

g++ -O -o test test1.C

to see it fail use:

g++ -O3 -funroll-loops -mcpu=pentiumpro -o test test1.C

or use simply:

g++ -O3 -o test test1.C

which is producing different results then above one.


Is there a workaround for this problem or is there a place where I can 
download a new binary?

Thanks

Ronald

[-- Attachment #2: test1.C --]
[-- Type: text/plain, Size: 1826 bytes --]

//
// g++  -O -o test test1.C          
// OK
//
// g++ -O3 -funroll-loops -Wuninitialized -mcpu=pentiumpro -Wno-deprecated -o test test1.C
// BUG

#include <cstring>
#include <cstdlib>
#include <iostream>

using namespace std;

#define NIL 1

short s_in[12];


class Cq_rab {
   public:
   int first;
   int last;
   int akt;
   int pred;
   int succ;
   int next;
   Cq_rab() {
      first=NIL;
      last=NIL;
      akt=NIL;
      pred=NIL;
      succ=NIL;
      next=NIL;
   };
};

inline int ReadDbRecHead(int *pred,int *succ,int *next, short *infopa, const int rec_no, const int dbunit) {
      int *adress, *iptr;
      
     // DbsFindReadAdr(dbunit, rec_no);
      adress = (int*)&s_in;
      iptr=(int*)infopa;
      *pred=*adress++;
      *succ=*adress++;
      *next=*adress++;
      *iptr++=*adress++;
      *iptr=*adress;
      return(*adress);
   }
   

inline void Gthdpa(int *objide, int *objqcn, int *objiln, int *objcln, Cq_rab *rab, int rcunit) {
      short infopa[4];
      
      ReadDbRecHead(&rab->pred,&rab->succ,&rab->next,infopa,rab->akt,rcunit);
      *objide = infopa[0];
      *objqcn = infopa[1];
      *objcln = infopa[2];
      *objiln = infopa[3];
      return;
   }


int main() {
   int      objcln, objide, objiln, objqcn;
   int   unit = 81;
   Cq_rab  rab;       
   s_in[6]=11111;
   s_in[7]=12222;
   s_in[8]=13333;
   s_in[9]=14444;
   //
   // If you uncomment the following lines, only the second line(value) is
   // wrong 
   //
   /* 
   short s_out[4];
   int   out[4];
   memcpy(s_out,s_in,8);
   out[0] = s_out[0];
   out[1] = s_out[1];
   out[2] = s_out[2];
   out[3] = s_out[3];
   */
   Gthdpa(&objide,&objqcn,&objiln,&objcln,&rab,unit);
   
   cout << objide << endl;
   cout << objqcn << endl;
   cout << objcln << endl;
   cout << objiln << endl;   
   return(0);
}   

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2003-04-18  7:43 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-04-17 20:10 gcc 3.3 -03 produces bad code Ronald Kukuck
2003-04-17 20:25 ` Daniel Jacobowitz
     [not found]   ` <20030418002154.5a50789b.ates100@web.de>
     [not found]     ` <20030417222524.GA28275@nevyn.them.org>
2003-04-17 23:01       ` type aliasing (was: gcc 3.3 -03 produces bad code) Tolga Dalman
2003-04-17 23:22         ` Daniel Jacobowitz
2003-04-17 23:38           ` Tolga Dalman
2003-04-18  0:27             ` Daniel Jacobowitz
2003-04-18  1:11               ` Tolga Dalman
2003-04-18 10:41             ` Andrew Haley

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).