Skip to main content
Post Made Community Wiki
Source Link
davidcary
  • 17.8k
  • 11
  • 68
  • 120

Yes, disabling optimizations during debugging has been best practice for a while now, for three reasons:

  • (a) if you're going to single-step the program with a high-level debugger, it's slightly less confusing.
  • (a) (obsolete) if you're going to single-step debug the program with an assembly-language debugger, it's much less confusing. (But why would you bother with this when you could be using a high-level debugger?)
  • (b) (long obsolete) you're probably going to only run this particular executable once, then make some change and recompile. It's a waste of a person's time to wait an extra 10 minutes while the compiler "optimizes" this particular executable, when that's going to save less than 10 minutes of runtime. (This is no longer relevant with modern PCs that can compile a typical microcontroller executable, with full optimization, in less than 2 seconds).

Many people go even further in this direction, and ship with assertions turned on.