https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65821

            Bug ID: 65821
           Summary: [4.8.2 regression] incorrect debug line # info for
                    main
           Product: gcc
           Version: 4.8.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: debug
          Assignee: unassigned at gcc dot gnu.org
          Reporter: chihin.ko at oracle dot com

this happen since 4.8.2, 4.9.0 also have same problem.

cat t.cc
==========================================================
  1 #include <stdio.h>
  2
  3 int b = 12;
  4
  5 inline void foo(const int &x = (b+3))
  6 {
  7     printf("%d\n", x);
  8 }   9
 10 inline void baz(const int &x = 200)
 11 {
 12     printf("%d\n", x);
 13 }
 14
 15 inline void bar(int &x = b)
 16 {  17     printf("%d\n", x);
 18     x = 100;
 19     printf("%d\n", x);
 20 }
 21
 22
 23 void
 24 bob(char *s = "hello")  25 {
 26     printf("%s\n", s);
 27 }  28
 29 int main()
 30 {
 31   foo();  32   baz();
 33   bar();
 34   bob();
 35   return 0;
 36 }
====================================================
The line table for main is incorrect:

< 1><0x0000067e>    DW_TAG_subprogram
                      DW_AT_external              yes(1)
                      DW_AT_name                  "main"
                      DW_AT_decl_file             0x00000001 t.cc
                      DW_AT_decl_line             0x0000001d
                      DW_AT_type                  <0x00000491>
                      DW_AT_low_pc                0x0040129f
                      DW_AT_high_pc               0x004012ff
.debug_line
---
....
0x0040129f  [  30, 0] NS
0x004012a7  [   5, 0] NS   <==== extra line info
0x004012b0  [  31, 0] NS
0x004012bf  [  32, 0] NS DI=0x1
0x004012d2  [  33, 0] NS
0x004012dc  [  34, 0] NS

This cause follwing problem:
(gdb) b main
Breakpoint 1 at 0x4006ea: file c++defargs3.cc, line 5.  <== should be line 31
(gdb) run
Starting program:
/workspace/chko/ws/dinstall/dbx_test/intel_S11_gcc482/c++defargs3.dbx,gcc/g47/a.out

Breakpoint 1, main () at c++defargs3.cc:5
5       inline void foo(const int &x = (b+3))

Reply via email to