Mail Archives: djgpp/2002/03/24/01:45:34
On Sat, 23 Mar 2002, CBFalconer wrote:
> Probably because optimization has rearranged the code.  Just turn
> it off (remove the -On compile flag, for whatever n you are using,
> probably 2).  Put it back when you are satisfied.
It's IMHO a bad idea to turn off optimizations when debugging a program.
Compilers these days do such complicated code changes when optimizing 
that you are effectively debugging a very different program.  So you 
either need to debug the program twice, first without optimizations, then 
with them (and who has the will power and resources to do that?), or use 
untested program when you turn on optimizations for production version.
Debugging optimized code takes some getting used to, but once you are 
there, it's not such a hard thing to do, especially with a powerful 
debugger such as GDB (RHIDE's debugging engine is based on GDB).  FWIW,
I miss this possibility badly when I work on some systems, such as 
Solaris, where the native compiler doesn't allow to mix debugging and 
optimization switches in the same compilation.
- Raw text -