[Bug debug/14048] New: [regression tree-ssa] bad debug line numbers near "return" statement, c++

mec dot gnu at mindspring dot com gcc-bugzilla@gcc.gnu.org
Fri Feb 6 14:44:00 GMT 2004


I have a simple C++ program with some instance variables:

  int main (void)
  {
    A alpha, *aap, *abp;
    B beta, *bbp;

    ...
    return 0;
  }

The command line is: gcc -S -gdwarf-2

The "return 0" line is on line 65.

With gcc HEAD 2004-02-01 15:37:18 UTC, the generated code for "return 0" looks
like this:

  .LBB10:
    .loc 1 65 0
    leal -56(%ebp), %eax
    movl %eax, (%esp)
    call B::~B [in-charge]()
    leal -24(%ebp), %eax
    movl %eax, (%esp)
    call A::~A [in-charge]()
  .LBE10:
    movl $0, %eax

Simple and good.  I can set a breakpoint on line 65, the "return 0" line, and
look at the values of A and B before they are destroyed.

With gcc tree-ssa-20020619-branch 2004-02-05 12:45:13 UTC, the generated code
looks like this:

    movl $0, %ebx
    .loc 1 56 0
    leal -56(%ebp), %eax
    movl %eax, (%esp)
    call B::~B [in-charge]()
    .loc 1 55 0
    leal -24(%ebp), %eax
    movl %eax, (%esp)
    call A::~A [in-charge]()
    movl %ebx, %eax
  .LBE2:
    .loc 1 66 0
    movl -4(%ebp), %ebx
    leave
    ret

The "return 0" line has had its code split up into two pieces, "movl 0, %ebx"
and "movl %ebx, %eax", which are separated.

There is no more .loc 1 65 at all.  Instead, there are some .loc lines for the
destructor calls which reference the lines that *declared* A and B.

When I try to break on line 65 and print "A" and "B", gdb selects the .loc for
line 66, which comes after the destructors, so the local instance variables have
been destroyed.

This happens with both dwarf-2 and stabs+.

There needs to be a ".loc 1 65" for the "return 0;" line, and it needs to occur
before the destructors.

-- 
           Summary: [regression tree-ssa] bad debug line numbers near
                    "return" statement, c++
           Product: gcc
           Version: tree-ssa
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: debug
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: mec dot gnu at mindspring dot com
                CC: gcc-bugs at gcc dot gnu dot org
 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=14048



More information about the Gcc-bugs mailing list