When you want to build something that\'s debuggable (g++ specifically, but perhaps shares an answer with gcc), what\'s the best -O level? In other words, when building a \"
GCC 4.8 introduces a new optimization level: -Og for the best of both worlds.
-Og
Optimize debugging experience. -Og enables optimizations that do not interfere with debugging. It should be the optimization level of choice for the standard edit-compile-debug cycle, offering a reasonable level of optimization while maintaining fast compilation and a good debugging experience.
This way some optimization is done so you get better performance, better possibly-uninitialized variable detection and you can also step through a program in GDB without jumping back-and-forth through the function.