--- Comment #7 from dodji at gcc dot gnu dot org 2010-03-18 12:50 ---
Things have changed quite a bit in GCC 4.5 (trunk).
Now for the code:
class C
{
static const int foo;
};
int
main()
{
return 0;
}
GCC 4.5 will not generate any debug info for the class C at all, because it's
not used. The compiler does that to minimize the size of debug info.
Now if we write:
class C
{
static const int foo;
};
int
main()
{
C c;
return 0;
}
GCC generates debug info for C, and properly generates a DW_TAG_member for foo.
Note how we instantiate C in main, but don't reference C::foo in any way.
Here is a relevant DWARF portion of the assembly we get for this:
.uleb128 0x2# (DIE (0x2d) DW_TAG_class_type)
.ascii "C\0"# DW_AT_name
.byte 0x1 # DW_AT_byte_size
.byte 0x1 # DW_AT_decl_file (../../prtests/test.cc)
.byte 0x2 # DW_AT_decl_line
.long 0x49# DW_AT_sibling
.uleb128 0x3# (DIE (0x37) DW_TAG_member)
.ascii "foo\0" # DW_AT_name
.byte 0x1 # DW_AT_decl_file (../../prtests/test.cc)
.byte 0x4 # DW_AT_decl_line
.long .LASF3 # DW_AT_MIPS_linkage_name: "_ZN1C3fooE"
.long 0x49# DW_AT_type
.byte 0x1 # DW_AT_external
.byte 0x1 # DW_AT_declaration
.byte 0x0 # end of children of DIE 0x2d
So I think we can close this bug now.
--
dodji at gcc dot gnu dot org changed:
What|Removed |Added
AssignedTo|unassigned at gcc dot gnu |dodji at gcc dot gnu dot org
|dot org |
Status|NEW |ASSIGNED
Last reconfirmed|2003-06-09 15:32:16 |2010-03-18 12:50:30
date||
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=7580