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

            Bug ID: 61574
           Summary: Confusing .debug_line generation by -g option
           Product: gcc
           Version: 4.8.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: jamesgua at ca dot ibm.com

#include <iostream>
#include <string>

using namespace std;

int main(int argc, char** argv)
{
  string str1 = "Hello";
  string str2;

  str2 = str1;
  cout << "str2: " << str2 << ", and same as str1: " << str1 << endl;

  str2 += "World!";
  cout << "Now str2: " << str2 << endl;

  return 0;
}

g++ -g -osample sample.cpp
gdb ./sample
...
Breakpoint 1, main (argc=1, argv=0x3ffffffff4f8) at sample.cpp:17
17        return 0;
(gdb) n
9         string str2;
(gdb)
17        return 0;
(gdb)
18      }
...
This is really confusing and out of sequential execution expectation. It
happens on x86_64/ppcl4le platform using g++ 4.8.2. 
Output from cmd: readelf --debug-dump=decodedline sample
...
sample.cpp                                    17          0x10000e90
sample.cpp                                     9          0x10000e94
sample.cpp                                    17          0x10000ea4
sample.cpp                                     9          0x10000ee4
sample.cpp                                    17          0x10000efc
...

Reply via email to