Path: utzoo!utgpu!news-server.csri.toronto.edu!mailrus!wuarchive!usc!sdd.hp.com!decwrl!uunet!tiamat!jim From: jim@tiamat.fsc.com (Jim O'Connor) Newsgroups: comp.sys.hp Subject: Re: C Compiler Optimizer Keywords: Optimizer C Complier Message-ID: <766@tiamat.fsc.com> Date: 28 Aug 90 13:06:07 GMT References: <59169@bbn.BBN.COM> Organization: Ahlstrom Filtration - Chattanooga,TN Lines: 46 In article <59169@bbn.BBN.COM>, ahill@bbn.com (Alan R. Hill) writes: > > We have experienced problems of varying symptoms while using > the optimizer switch of the HP-UX 7.0 C compiler. Rather than > extensively analyzing these problems we have opted to compile without > optimizing. Has anyone else noticed bad behavior with the optimizer? > Yes, we have, too. One example that comes to mind is: (this is simplified, the actual program we used was much longer) example.c ------ main() { printf("hello, world\n"); } $ cc -o example example.c $ example hello, world $ echo $? 0 $ cc -O -o example example.c $ example hello, world $ echo $? seemingly random numbers, but not once 0 I didn't really worry about this, telling myself that not using "exit(0)" at the "normal" exit point of the program was probably bad programming practice. Using the optimizer also helped to point out another bad habit of mine (learned while programming on Xenix) which is not correctly initializing automatic variables. In one case we had, with the optimizer off, the automotic variable was being initialized (i.e. set to 0), but then when we did the "production" compile and test, the program didn't work because the variable wasn't initialized. Like the other one, it wasn't really the compilers fault, but I wish there was more info on what the optimizer will do so I won't get suprised on things like this. ------------- James B. O'Connor jim@tiamat.fsc.com Ahlstrom Filtration, Inc. 615/821-4022 x. 651