http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60948
Bug ID: 60948 Summary: incorrect debug info for reference type of function parameters Product: gcc Version: 4.8.2 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: chihin.ko at oracle dot com cat t.cc #include <stdio.h> int f(int &r) { r = r + 1; return r; } main(void) { int j = 99; int i = 99; printf("i = %d\n",i); printf("f(i) = %d\n",f(i)); printf("i = %d\n",i); return 0; } (dbx) stop at 11;run (2) stop at "calls_with_refs.cc":11 Running: a.out (process id 14632) stopped in main at line 11 in file "calls_with_refs.cc" 11 int i = 99; (dbx) call f(33) <== should have errmsg "dbx: The ref (&) parameters to `f' cannot be literals" ------------------------------------------------------------------------- this is due to g++ generate wrong debug info for function f(int &), there is an extra "const" , f(const int &), if there is no "const", then call "f" with constant e.g. f(33), is illegal, if there is "const", then "call f(33)" is legal. -------------------------------------------------------------------- There is an extra DW_TAG_const_type for parameter "r" of function "f" < 2><0x00000482> DW_TAG_formal_parameter DW_AT_name "r" DW_AT_decl_line 0x00000003 DW_AT_type <0x0000048f> ... ... < 1><0x0000048f> DW_TAG_const_type <== should not have this TAG DW_AT_type <0x00000494>