https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61755
Bug ID: 61755 Summary: Reference to function is parsed as const reference to function in debug info Product: gcc Version: 4.7.2 Status: UNCONFIRMED Severity: minor Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: sijun.liu at oracle dot com ------------------ t.cc ---------------- int foo(){ return 2; } int main(){ int (&g)() = foo; return 1; } ---------------------------------------- Use g++ version 4.8.2 on intel Solaris 10, and Solaris studio debugger dbx, it says the type of g is int (&const g)(), while it should be int (& g)(). bash-3.2$ g++ -g -std=c++11 t.cc bash-3.2$ dbx a.out For information about new features see `help changes' To remove this message, put `dbxenv suppress_startup_message 8.0' in your .dbxrcReading a.out Reading ld.so.1 Reading libstdc++.so.6.0.18 Reading libm.so.2 Reading libgcc_s.so.1 Reading libc.so.1 (dbx) stop at 7 (2) stop at "t.cc":7 (dbx) run Running: a.out (process id 6747) stopped in main at line 7 in file "t.cc" 7 return 1; (dbx) whatis g int (&const g)(); <========= ERROR!! (dbx) quit The following is the debug info using Oracle dwarf dump, where the type of function g is <0x000000f2>, and the type at <0x000000f2> is DW_TAG_const_type, which is wrong. ------------------------------------------ bash-3.2$ dwarfdump a.out .debug_info: COMPILE_UNIT<header overall offset = 0x00000000>: < 0><0x0000000b> DW_TAG_compile_unit DW_AT_producer "GNU C++ 4.8.2 -mtune=generic -m arch=pentium4 -g -std=c++11" DW_AT_language DW_LANG_C_plus_plus DW_AT_name "t.cc" DW_AT_comp_dir "/workspace" DW_AT_low_pc 0x08050c3e DW_AT_high_pc 0x08050c5c DW_AT_stmt_list 0x00000000 LOCAL_SYMBOLS: < 1><0x00000090> DW_TAG_subprogram DW_AT_external yes(1) DW_AT_name "foo" DW_AT_decl_file 0x00000001 /workspace/t.cc DW_AT_decl_line 0x00000001 DW_AT_MIPS_linkage_name "_Z3foov" DW_AT_type <0x000000b1> DW_AT_low_pc 0x08050c3e DW_AT_high_pc 0x08050c48 DW_AT_frame_base <loclist with 4 entries follow s> [ 0]<lowpc=0x00000000><highpc=0x00000001>DW_OP_breg4+4 [ 1]<lowpc=0x00000001><highpc=0x00000003>DW_OP_breg4+8 [ 2]<lowpc=0x00000003><highpc=0x00000009>DW_OP_breg5+8 [ 3]<lowpc=0x00000009><highpc=0x0000000a>DW_OP_breg4+4 DW_AT_GNU_all_call_sites yes(1) < 1><0x000000b1> DW_TAG_base_type DW_AT_byte_size 0x00000004 DW_AT_encoding DW_ATE_signed DW_AT_name "int" < 1><0x000000b8> DW_TAG_subprogram DW_AT_external yes(1) DW_AT_name "main" DW_AT_decl_file 0x00000001 /workspace/t.cc DW_AT_decl_line 0x00000005 DW_AT_type <0x000000b1> DW_AT_low_pc 0x08050c48 DW_AT_high_pc 0x08050c5c DW_AT_frame_base <loclist with 4 entries follow s> [ 0]<lowpc=0x0000000a><highpc=0x0000000b>DW_OP_breg4+4 [ 1]<lowpc=0x0000000b><highpc=0x0000000d>DW_OP_breg4+8 [ 2]<lowpc=0x0000000d><highpc=0x0000001d>DW_OP_breg5+8 [ 3]<lowpc=0x0000001d><highpc=0x0000001e>DW_OP_breg4+4 DW_AT_GNU_all_call_sites yes(1) DW_AT_sibling <0x000000ed> < 2><0x000000d6> DW_TAG_lexical_block DW_AT_low_pc 0x08050c4e DW_AT_high_pc 0x08050c5a < 3><0x000000df> DW_TAG_variable DW_AT_name "g" DW_AT_decl_file 0x00000001 /workspace/t.cc DW_AT_decl_line 0x00000006 DW_AT_type <0x000000f2> DW_AT_location DW_OP_fbreg -12 < 1><0x000000ed> DW_TAG_subroutine_type DW_AT_type <0x000000b1> < 1><0x000000f2> DW_TAG_const_type DW_AT_type <0x000000f7> < 1><0x000000f7> DW_TAG_reference_type DW_AT_byte_size 0x00000004 DW_AT_type <0x000000ed> File table: 1 entries [ 1] /workspace/t.cc (below is omitted...)