Use -O1 optimization but avoid <optimized out>?

Marc Glisse marc.glisse@inria.fr
Sun Apr 5 07:54:00 GMT 2015


On Sat, 4 Apr 2015, Jeffrey Walton wrote:

> I'm currently building with -O1 and -g3, and I'm seeing values as
> <optimized out> under the debugger. This is expected (but not
> desired).
>
> I'm interested in building my program with -O1 to invoke analysis for
> the warnings I have enabled. But I don't want the resulting binary to
> have values optimized out when viewing them under the debugger.
>
> Is there a way to use -O1 (for warnings and analysis) but avoid
> <optimized out> (for debugging)? If so, then how would I go about it?

-Og could help with recent versions, but not as much as compiling several 
times with different options.

-- 
Marc Glisse



More information about the Gcc-help mailing list