When I compile a program that uses pointers to member functions, GCC emits DWARF claiming that the pmf has the type 'struct { X (*__pfn)(Y); int __delta }'. I would expect it to produce a DW_TAG_ptr_to_member_type DIE whose DW_AT_type attribute was a function type.
I've checked that this problem exists in the current head (r157312). To reproduce: $ cat mp.ii struct S { int b; int foo(int x) { return b+x; } }; int f(S &s, int (S::*pimf)(int)) { return (s.*pimf)(42); } $ with-my-gcc g++ --version g++ (GCC) 4.5.0 20100309 (experimental) Copyright (C) 2010 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. $ with-my-gcc g++ -c -g mp.ii $ readelf -wi mp.o Contents of the .debug_info section: Compilation Unit @ offset 0x0: Length: 0xe7 (32-bit) Version: 2 Abbrev Offset: 0 Pointer Size: 4 <0><b>: Abbrev Number: 1 (DW_TAG_compile_unit) < c> DW_AT_producer : (indirect string, offset: 0x24): GNU C++ 4.5.0 20100309 (experimental) <10> DW_AT_language : 4 (C++) <11> DW_AT_name : (indirect string, offset: 0x72): mp.ii <15> DW_AT_comp_dir : (indirect string, offset: 0x0): /home/jimb/play/cpp-member-pointers <19> DW_AT_low_pc : 0x0 <1d> DW_AT_high_pc : 0x3d <21> DW_AT_stmt_list : 0x0 <1><25>: Abbrev Number: 2 (DW_TAG_structure_type) <26> DW_AT_name : S <28> DW_AT_byte_size : 4 <29> DW_AT_decl_file : 1 <2a> DW_AT_decl_line : 1 <2b> DW_AT_sibling : <0x59> <2><2f>: Abbrev Number: 3 (DW_TAG_member) <30> DW_AT_name : b <32> DW_AT_decl_file : 1 <33> DW_AT_decl_line : 2 <34> DW_AT_type : <0x59> <38> DW_AT_data_member_location: 2 byte block: 23 0 (DW_OP_plus_uconst: 0) <2><3b>: Abbrev Number: 4 (DW_TAG_subprogram) <3c> DW_AT_external : 1 <3d> DW_AT_name : foo <41> DW_AT_decl_file : 1 <42> DW_AT_decl_line : 3 <43> DW_AT_MIPS_linkage_name: (indirect string, offset: 0x66): _ZN1S3fooEi <47> DW_AT_type : <0x59> <4b> DW_AT_declaration : 1 <3><4c>: Abbrev Number: 5 (DW_TAG_formal_parameter) <4d> DW_AT_type : <0x60> <51> DW_AT_artificial : 1 <3><52>: Abbrev Number: 6 (DW_TAG_formal_parameter) <53> DW_AT_type : <0x59> <1><59>: Abbrev Number: 7 (DW_TAG_base_type) <5a> DW_AT_byte_size : 4 <5b> DW_AT_encoding : 5 (signed) <5c> DW_AT_name : int <1><60>: Abbrev Number: 8 (DW_TAG_pointer_type) <61> DW_AT_byte_size : 4 <62> DW_AT_type : <0x25> <1><66>: Abbrev Number: 9 (DW_TAG_subprogram) <67> DW_AT_external : 1 <68> DW_AT_name : f <6a> DW_AT_decl_file : 1 <6b> DW_AT_decl_line : 6 <6c> DW_AT_MIPS_linkage_name: (indirect string, offset: 0x52): _Z1fR1SMS_FiiE <70> DW_AT_type : <0x59> <74> DW_AT_low_pc : 0x0 <78> DW_AT_high_pc : 0x3d <7c> DW_AT_frame_base : 0x0 (location list) <80> DW_AT_sibling : <0x9f> <2><84>: Abbrev Number: 10 (DW_TAG_formal_parameter) <85> DW_AT_name : s <87> DW_AT_decl_file : 1 <88> DW_AT_decl_line : 6 <89> DW_AT_type : <0x9f> <8d> DW_AT_location : 2 byte block: 91 0 (DW_OP_fbreg: 0) <2><90>: Abbrev Number: 11 (DW_TAG_formal_parameter) <91> DW_AT_name : (indirect string, offset: 0x61): pimf <95> DW_AT_decl_file : 1 <96> DW_AT_decl_line : 6 <97> DW_AT_type : <0xaa> <9b> DW_AT_location : 2 byte block: 91 4 (DW_OP_fbreg: 4) <1><9f>: Abbrev Number: 12 (DW_TAG_const_type) <a0> DW_AT_type : <0xa4> <1><a4>: Abbrev Number: 13 (DW_TAG_reference_type) <a5> DW_AT_byte_size : 4 <a6> DW_AT_type : <0x25> <1><aa>: Abbrev Number: 14 (DW_TAG_structure_type) <ab> DW_AT_byte_size : 8 <ac> DW_AT_decl_file : 2 <ad> DW_AT_decl_line : 0 <ae> DW_AT_sibling : <0xcf> <2><b2>: Abbrev Number: 15 (DW_TAG_member) <b3> DW_AT_name : (indirect string, offset: 0x78): __pfn <b7> DW_AT_decl_file : 1 <b8> DW_AT_decl_line : 6 <b9> DW_AT_type : <0xe4> <bd> DW_AT_data_member_location: 2 byte block: 23 0 (DW_OP_plus_uconst: 0) <2><c0>: Abbrev Number: 15 (DW_TAG_member) <c1> DW_AT_name : (indirect string, offset: 0x4a): __delta <c5> DW_AT_decl_file : 1 <c6> DW_AT_decl_line : 6 <c7> DW_AT_type : <0x59> <cb> DW_AT_data_member_location: 2 byte block: 23 4 (DW_OP_plus_uconst: 4) <1><cf>: Abbrev Number: 16 (DW_TAG_subroutine_type) <d0> DW_AT_type : <0x59> <d4> DW_AT_sibling : <0xe4> <2><d8>: Abbrev Number: 5 (DW_TAG_formal_parameter) <d9> DW_AT_type : <0x60> <dd> DW_AT_artificial : 1 <2><de>: Abbrev Number: 6 (DW_TAG_formal_parameter) <df> DW_AT_type : <0x59> <1><e4>: Abbrev Number: 8 (DW_TAG_pointer_type) <e5> DW_AT_byte_size : 4 <e6> DW_AT_type : <0xcf> $ -- Summary: G++ emits bad DWARF for pointers to member functions Product: gcc Version: 4.5.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: jimb at red-bean dot com GCC build triplet: i686-pc-linux-gnu GCC host triplet: i686-pc-linux-gnu GCC target triplet: i686-pc-linux-gnu http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43312