------- Comment #4 from dodji at gcc dot gnu dot org 2008-11-01 11:03 ------- I could reproduce this on 4.3 and trunk (4.4).
Actually I think there are several problems here. First, I think the DIE representing the defining declaration of A::elsewhere in class2.c should have a DW_AT_specification pointing back to the DIE representing the declaration or A::elsewhere in class.h. That can be deduced from the dwarf2 spec, section [4.1 Data Object Entries], point 5, pdf page 35, spec page 33 that reads: "5. If the variable entry represents the defining declaration for a C++ static data member of a structure, class or union, the entry has a DW_AT_specification attribute, whose value is a reference to the debugging information entry representing the declaration of this data member. The referenced entry will be a child of some class, structure or union type entry.". Second, I think the DIE of the defining declaration of A::elsewhere in class2 should have a DW_AT_const_value attribute whose value should be the constant "211". This can be deduced from the dwarf2 spec, section [4.1 Data Object Entries], point 9, pdf page 35, spec page 33 that reads: "9. An entry describing a variable whose value is constant and not represented by an object in the address space of the program, or an entry describing a named constant, does not have a location attribute. Such entries have a DW_AT_const_value attribute, whose value may be a string or any of the constant data or data block forms, as appropriate for the representation of the variables value. The value of this attribute is the actual constant value of the variable, represented as it would be on the target architecture." And third, as you pointed out, the DIE of the declaration of A::elsewhere should not appear twice in the class.c compilation unit. It should only appear once, in the scope of the A class. -- dodji at gcc dot gnu dot org changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |dodji at gcc dot gnu dot org Status|UNCONFIRMED |NEW Ever Confirmed|0 |1 Last reconfirmed|0000-00-00 00:00:00 |2008-11-01 11:03:52 date| | http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37982