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 <0x00f2>, and the type at <0x00f2> is DW_TAG_const_type,
which is wrong.
--
bash-3.2$ dwarfdump a.out
.debug_info:
COMPILE_UNIT:
< 0><0x000b> 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_pc0x08050c3e
DW_AT_high_pc 0x08050c5c
DW_AT_stmt_list 0x
LOCAL_SYMBOLS:
< 1><0x0090>DW_TAG_subprogram
DW_AT_external yes(1)
DW_AT_name "foo"
DW_AT_decl_file 0x0001 /workspace/t.cc
DW_AT_decl_line 0x0001
DW_AT_MIPS_linkage_name "_Z3foov"
DW_AT_type <0x00b1>
DW_AT_low_pc0x08050c3e
DW_AT_high_pc 0x08050c48
DW_AT_frame_base
[ 0]DW_OP_breg4+4
[ 1]DW_OP_breg4+8
[ 2]DW_OP_breg5+8
[ 3]DW_OP_breg4+4
DW_AT_GNU_all_call_sitesyes(1)
< 1><0x00b1>DW_TAG_base_type
DW_AT_byte_size 0x0004
DW_AT_encoding DW_ATE_signed
DW_AT_name "int"
< 1><0x00b8>DW_TAG_subprogram
DW_AT_external yes(1)
DW_AT_name "main"
DW_AT_decl_file 0x0001 /workspace/t.cc
DW_AT_decl_line 0x0005
DW_AT_type <0x00b1>
DW_AT_low_pc0x08050c48
DW_AT_high_pc 0x08050c5c
DW_AT_frame_base
[ 0]DW_OP_breg4+4
[ 1]DW_OP_breg4+8
[ 2]DW_OP_breg5+8
[ 3]DW_OP_breg4+4
DW_AT_GNU_all_call_sitesyes(1)
DW_AT_sibling <0x00ed>
< 2><0x00d6> DW_TAG_lexical_block
DW_AT_low_pc0x08050c4e
DW_AT_high_pc 0x08050c5a
< 3><0x00df>DW_TAG_variable
DW_AT_name "g"
DW_AT_decl_file 0x0001
/workspace/t.cc
DW_AT_decl_line 0x0006
DW_AT_type <0x00f2>
DW_AT_location DW_OP_fbreg -12
< 1><0x00ed>DW_TAG_subroutine_type
DW_AT_type <0x00b1>
< 1><0x00f2>DW_TAG_const_type
DW_AT_type <0x00f7>
< 1><0x00f7>DW_TAG_reference_type
DW_AT_byte_size 0x0004
DW_AT_type <0x00ed>
File table: 1 entries
[ 1] /workspace/t.cc
(below is omitted...)