cURL / Mailing Lists / curl-library / Single Mail

curl-library

RE: gcc warnings in non-debug builds

From: Patrick Monnerat <Patrick.Monnerat_at_datasphere.ch>
Date: Thu, 2 Oct 2008 17:21:20 +0200

Yang Tse wrote:

> I suppose that with --enable-debug we want CFLAGS with '-g -O2' for
debug builds to actually exercise the '-O2' optimizations and be able to
properly 'dbg' coredumps. True?

Personally, I really hate real debugging with -O2, because optimization
hides some variables, delays some assignments, causes strange jumpy
stepping in gdb, etc. I rather use -O0.

The only case I use optimization with -g is when the non-optimized
version behaves OK while the optimized one does not: Generally, this is
the indication of memory pointer bugs or... optimizer bugs. The later
are out of topic.

Fedora distro uses "-O2 -g" for nearly all their packages because they
want to have a single package version, and they provide a "debuginfo"
package containing only the extracted debuginfo. But their goal is not
real debugging: debuginfo packages are made available to help bug
reporters to provide crash info about the distibuted package.

In other words, optimizing a debug version or not depends mainly if you
want to perform live debugging (i.e. run under control of gdb) or
post-mortem-dump analysis. As a developer, I'm 99% in the former case.

Just my 2 cents...
Regards,
Patrick
Received on 2008-10-02