home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c++
- Path: sparky!uunet!taumet!steve
- From: steve@taumet.com (Steve Clamage)
- Subject: Re: Optimized C++ library
- Message-ID: <1993Jan22.195608.13406@taumet.com>
- Organization: TauMetric Corporation
- References: <1jng9aINN39s@male.EBay.Sun.COM>
- Date: Fri, 22 Jan 1993 19:56:08 GMT
- Lines: 29
-
- pauln@loopkill.EBay.Sun.COM (Paul Nguyen) writes:
-
-
- >We have an application that runs OK when all the libraries were compiled with the
- >-g option. But when the libraries were re-compiled with -O for optimization. The
- >application seems to crash randomly in one of the library. The library that it
- >crashes in was entirely written in C++ with inheritance, etc...
-
- >Is it possible that compiling with -O uncovered a bug?
-
-
- Of course. It is also possible for compiling with -O to hide a bug.
-
- For example, suppose you have a wild pointer in your program
- (uninitialized or dangling). When you use the pointer, some arbitrary
- piece of memory will be accessed (or access attempted). Since the
- stack and code layout is usually different with and without debugging,
- you might get a harmless reference in one case, and a fatal mistake
- in the other case.
-
- Alternatively, the compiler might have an error in its optimizer. I
- would not suspect this (unless the optimizer is known to have problems)
- until you know that you don't have bugs in your code.
-
- Quick experiment: compile without debug and without optimization.
- If the code still fails, it is probably your code, not the compiler.
- --
-
- Steve Clamage, TauMetric Corp, steve@taumet.com
-