Bug 43053 - DWARF info adds bogus const to 'this' argument
Summary: DWARF info adds bogus const to 'this' argument
Status: UNCONFIRMED
Alias: None
Product: gcc
Classification: Unclassified
Component: debug (show other bugs)
Version: 4.5.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: wrong-debug
Depends on:
Blocks:
 
Reported: 2010-02-12 15:03 UTC by Daniel Jacobowitz
Modified: 2022-01-06 11:24 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Daniel Jacobowitz 2010-02-12 15:03:14 UTC
Compile this code (from the GDB testsuite) with G++ (tested 4.4.3, trunk):

class foo {
public:
  int overload1arg (char);
};


int main ()
{
    foo foo_instance1;
    return 0;
}

int foo::overload1arg (char arg)            { arg = 0; return 2;}

Here's the relevant bit of debug info:

 <2><2d>: Abbrev Number: 3 (DW_TAG_subprogram)
    <2e>   DW_AT_external    : 1
    <2f>   DW_AT_name        : (indirect string, offset: 0x59): overload1arg
    <33>   DW_AT_decl_file   : 1
    <34>   DW_AT_decl_line   : 3
    <35>   DW_AT_MIPS_linkage_name: (indirect string, offset: 0x0): _ZN3foo12overload1argEc
    <39>   DW_AT_type        : <0x4b>
    <3d>   DW_AT_declaration : 1
 <3><3e>: Abbrev Number: 4 (DW_TAG_formal_parameter)
    <3f>   DW_AT_type        : <0x52>
    <43>   DW_AT_artificial  : 1
 <3><44>: Abbrev Number: 5 (DW_TAG_formal_parameter)
    <45>   DW_AT_type        : <0x58>

 <1><94>: Abbrev Number: 12 (DW_TAG_subprogram)
    <95>   DW_AT_specification: <0x2d>
    <99>   DW_AT_decl_line   : 13
    <9a>   DW_AT_low_pc      : 0xe
    <9e>   DW_AT_high_pc     : 0x25
    <a2>   DW_AT_frame_base  : 0x38     (location list)
    <a6>   DW_AT_sibling     : <0xc6>
 <2><aa>: Abbrev Number: 13 (DW_TAG_formal_parameter)
    <ab>   DW_AT_name        : (indirect string, offset: 0x66): this
    <af>   DW_AT_type        : <0xc6>
    <b3>   DW_AT_artificial  : 1
    <b4>   DW_AT_location    : 2 byte block: 91 0       (DW_OP_fbreg: 0)
 <2><b7>: Abbrev Number: 14 (DW_TAG_formal_parameter)
    <b8>   DW_AT_name        : arg
    <bc>   DW_AT_decl_file   : 1
    <bd>   DW_AT_decl_line   : 13
    <be>   DW_AT_type        : <0x58>
    <c2>   DW_AT_location    : 2 byte block: 91 64      (DW_OP_fbreg: -28)
 <1><c6>: Abbrev Number: 15 (DW_TAG_const_type)
    <c7>   DW_AT_type        : <0x52>

The in-class declaration of foo::overload1arg function has two arguments, of types <0x52> and <0x58>.  The out of line version references that with DW_AT_specification, but has argument types <0xc6> and <0x58>.  The specification has a foo * argument, the implementation has a foo * const argument.

'this' can not be modified, so arguably the const is right.  But it should be consistent between the two DIEs.
Comment 1 Mark Wielaard 2014-02-25 11:04:52 UTC
Same inconsistency with current g++ (GCC) 4.9.0 20140219 (experimental)