Given a testcase like this (reduced from a huge testcase submitted by a customer): struct foo { ~foo() {} }; int main(int i, char *p[]) { int late = i; if (late) { foo unused; } switch (i) { default: foo bar; break; } foo late_scope; } Debug information for the variable late is there, but in a lexical block that starts close to the end of the function, so you can't see the variable in gdb unless you are at the point where late_scope is already in scope.
With -g -O0 or with -O1 and higher? With optimization on, that should be well expected.
Created attachment 102642 [details] back-port of patch that fixed the bug in 3.4 This is a trivial back-port of http://gcc.gnu.org/ml/gcc-patches/2002-12/msg00862.html I still haven't run it through the regression tester, but I've verified that it fixes the debug information produced for the simplified testcase.
g++ -g -O0.
Created attachment 102686 [details] Reverts a patchlet obsoleted by the back-port, re-enabling NVR Turns out Jakub noticed the patch introduced a regression in the named return value optimization. That's because 3.2 and 3.3 have a patch to work around the very absence of the additional artificial block, as discussed in the thread starting at http://gcc.gnu.org/ml/gcc-patches/2003-03/msg01559.html, with the fix for http://gcc.gnu.org/PR9993. After back-porting the patch that introduced the additional scope, we have to revert that bit of the patch. This is what the attached patch does.
An errata has been issued which should help the problem described in this bug report. This report is therefore being closed with a resolution of ERRATA. For more information on the solution and/or where to find the updated files, please follow the link below. You may reopen this bug report if the solution does not work for you. http://rhn.redhat.com/errata/RHBA-2004-442.html