This is the mail archive of the gdb@sources.redhat.com mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Why GCC/ GDB ignore a normal C statement?


> Date: Tue, 6 May 2003 07:51:59 -0500
> From: Jim Robertson <robertso@somerset.sps.mot.com>
> > 
> > Optimization should be used only for the final
> > release. This is a common mistake made by new users.
> 
> This may be getting (a little) off topic, but I disagree with the
> above.  Only turning on optimizations for a "final release" can have
> unexpected consequences.  Optimizations have a way of uncovering bugs
> that go undetected in non-optimized code.  At a minimum, testing should
> be done with optimizations.  Preferably, all development is done with
> optimizations.

I certainly second that.  I do all my debugging builds with the full
set of optimizations options.  Modern debuggers no longer require you
to choose between -g and -O; GDB certainly doesn't.

A program compiled with and without optimizations are actually twio
very different programs.  So all of your test runs actually test a
program that is different from what you are going to ship.

Someone wise once compared testing an unoptimized program, then
turning on optimization for the release to learning to swim in shallow
waters with all the safety gear on, then throwing away that gear when
you first plunge into the deep.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]