This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/65108] New: Missing DWARF info for static const class members
- From: "wingo at igalia dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Wed, 18 Feb 2015 14:22:04 +0000
- Subject: [Bug c++/65108] New: Missing DWARF info for static const class members
- Auto-submitted: auto-generated
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65108
Bug ID: 65108
Summary: Missing DWARF info for static const class members
Product: gcc
Version: 4.9.2
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: wingo at igalia dot com
Compiling the following C++ program does not residualize DWARF info for
Foo::one, but does for Bar::two, even though Foo::one is used and Bar::two is
not.
$ cat <<END > foo.cc
class Foo {
public:
static const int one = 1;
};
namespace Bar {
static const int two = 2;
}
int main (int argc, char* argv[])
{
return Foo::one;
}
END
$ g++ --version | head -1
g++ (Debian 4.9.2-10) 4.9.2
$ g++ -Wall -g -O0 foo.cc
$ objdump --dwarf=info a.out
a.out: file format elf64-x86-64
Contents of the .debug_info section:
Compilation Unit @ offset 0x0:
Length: 0xaa (32-bit)
Version: 4
Abbrev Offset: 0x0
Pointer Size: 8
<0><b>: Abbrev Number: 1 (DW_TAG_compile_unit)
<c> DW_AT_producer : (indirect string, offset: 0x1b): GNU C++ 4.9.2
-mtune=generic -march=x86-64 -g -O0
<10> DW_AT_language : 4 (C++)
<11> DW_AT_name : (indirect string, offset: 0x0): /tmp/foo.cc
<15> DW_AT_low_pc : 0x400576
<1d> DW_AT_high_pc : 0x12
<25> DW_AT_stmt_list : 0x0
<1><29>: Abbrev Number: 2 (DW_TAG_const_type)
<2a> DW_AT_type : <0x2e>
<1><2e>: Abbrev Number: 3 (DW_TAG_base_type)
<2f> DW_AT_byte_size : 4
<30> DW_AT_encoding : 5 (signed)
<31> DW_AT_name : int
<1><35>: Abbrev Number: 4 (DW_TAG_subprogram)
<36> DW_AT_external : 1
<36> DW_AT_name : (indirect string, offset: 0x16): main
<3a> DW_AT_decl_file : 1
<3b> DW_AT_decl_line : 10
<3c> DW_AT_type : <0x2e>
<40> DW_AT_low_pc : 0x400576
<48> DW_AT_high_pc : 0x12
<50> DW_AT_frame_base : 1 byte block: 9c (DW_OP_call_frame_cfa)
<52> DW_AT_GNU_all_call_sites: 1
<52> DW_AT_sibling : <0x73>
<2><56>: Abbrev Number: 5 (DW_TAG_formal_parameter)
<57> DW_AT_name : (indirect string, offset: 0xc): argc
<5b> DW_AT_decl_file : 1
<5c> DW_AT_decl_line : 10
<5d> DW_AT_type : <0x2e>
<61> DW_AT_location : 2 byte block: 91 6c (DW_OP_fbreg: -20)
<2><64>: Abbrev Number: 5 (DW_TAG_formal_parameter)
<65> DW_AT_name : (indirect string, offset: 0x4d): argv
<69> DW_AT_decl_file : 1
<6a> DW_AT_decl_line : 10
<6b> DW_AT_type : <0x73>
<6f> DW_AT_location : 2 byte block: 91 60 (DW_OP_fbreg: -32)
<2><72>: Abbrev Number: 0
<1><73>: Abbrev Number: 6 (DW_TAG_pointer_type)
<74> DW_AT_byte_size : 8
<75> DW_AT_type : <0x79>
<1><79>: Abbrev Number: 6 (DW_TAG_pointer_type)
<7a> DW_AT_byte_size : 8
<7b> DW_AT_type : <0x7f>
<1><7f>: Abbrev Number: 7 (DW_TAG_base_type)
<80> DW_AT_byte_size : 1
<81> DW_AT_encoding : 6 (signed char)
<82> DW_AT_name : (indirect string, offset: 0x11): char
<1><86>: Abbrev Number: 8 (DW_TAG_namespace)
<87> DW_AT_name : Bar
<8b> DW_AT_decl_file : 1
<8c> DW_AT_decl_line : 6
<8d> DW_AT_sibling : <0x9e>
<2><91>: Abbrev Number: 9 (DW_TAG_variable)
<92> DW_AT_name : two
<96> DW_AT_decl_file : 1
<97> DW_AT_decl_line : 7
<98> DW_AT_type : <0x29>
<9c> DW_AT_declaration : 1
<9c> DW_AT_const_value : 2
<2><9d>: Abbrev Number: 0
<1><9e>: Abbrev Number: 10 (DW_TAG_variable)
<9f> DW_AT_specification: <0x91>
<a3> DW_AT_location : 9 byte block: 3 14 6 40 0 0 0 0 0
(DW_OP_addr: 400614)
<1><ad>: Abbrev Number: 0
Note the presence of Bar::two, but not Foo::one.
Could be related to bug 56251. If I instantiate Foo, then Foo::one debuginfo
is indeed serialized, so this problem only manifests itself for classes that
are not designed to be instantiated -- arguably a bad idiom, but not incorrect,
to my limited knowledge.