Compile this C++ code with -g enum x { i = 1 }; class c { static const x beg = i; }; void bar () { }
Looking at the .s output and the readelf --debug-dump output will show that there is no debug info for x or beg. This is as expected: they are not used by any actual code, so there is no need to emit debug info for them. Now compile this code, which adds an unused inline function: enum x { i = 1 }; class c { static const x beg = i; int foo () { return (int) beg; } }; void bar () { } Now I see debug info for enum x and for the const beg. However, there is no debug info for the unused inline function foo. There should not be any debug info for the enum or the const either. This matters particularly because these cases arise in ordinary C++ code, and in particular in the libstdc++ headers. For example, when I compile this file with -g: #include <iostream> void bar () { } I get over 27K of debug info. That's pretty bad. This was better in gcc 4.0.1. For that, I get 9K of debug info for the <iostream> example--not great, but much better. It changed in gcc 4.0.2. I believe the change was due to the patch for PR 23190, by RTH on 2005-09-08. I don't have a patch for this. I'm recording it so that I don't forget it. -- Summary: Unnecessary debug info for unused consts in C++ Product: gcc Version: 4.2.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: ian at airs dot com http://gcc.gnu.org/bugzilla/show_bug.cgi?id=26965