home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #3 / NN_1993_3.iso / spool / comp / lang / cplus / 19779 < prev    next >
Encoding:
Text File  |  1993-01-23  |  1.5 KB  |  40 lines

  1. Newsgroups: comp.lang.c++
  2. Path: sparky!uunet!taumet!steve
  3. From: steve@taumet.com (Steve Clamage)
  4. Subject: Re: Optimized C++ library
  5. Message-ID: <1993Jan22.195608.13406@taumet.com>
  6. Organization: TauMetric Corporation
  7. References: <1jng9aINN39s@male.EBay.Sun.COM>
  8. Date: Fri, 22 Jan 1993 19:56:08 GMT
  9. Lines: 29
  10.  
  11. pauln@loopkill.EBay.Sun.COM (Paul Nguyen) writes:
  12.  
  13.  
  14. >We have an application that runs OK when all the libraries were compiled with the
  15. >-g option.  But when the libraries were re-compiled with -O for optimization.  The
  16. >application seems to crash randomly in one of the library.  The library that it
  17. >crashes in was entirely written in C++ with inheritance, etc...
  18.  
  19. >Is it possible that compiling with -O uncovered a bug?
  20.  
  21.  
  22. Of course.  It is also possible for compiling with -O to hide a bug.
  23.  
  24. For example, suppose you have a wild pointer in your program
  25. (uninitialized or dangling).  When you use the pointer, some arbitrary
  26. piece of memory will be accessed (or access attempted).  Since the
  27. stack and code layout is usually different with and without debugging,
  28. you might get a harmless reference in one case, and a fatal mistake
  29. in the other case.
  30.  
  31. Alternatively, the compiler might have an error in its optimizer.  I
  32. would not suspect this (unless the optimizer is known to have problems)
  33. until you know that you don't have bugs in your code.
  34.  
  35. Quick experiment: compile without debug and without optimization.
  36. If the code still fails, it is probably your code, not the compiler.
  37. -- 
  38.  
  39. Steve Clamage, TauMetric Corp, steve@taumet.com
  40.