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

            Bug ID: 80629
           Summary: Missing .loc for a function in the presence of -O2
           Product: gcc
           Version: 7.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: debug
          Assignee: unassigned at gcc dot gnu.org
          Reporter: matt at godbolt dot org
  Target Milestone: ---

Firstly; I appreciate how tricky it is to keep track of debug information in
the presence of optimization and inlining, but I wonder if there's something
specific happening in this case. This is filed against 7.1, but previous
versions had slightly different, but similar issues.

In the following code snippet:

---cut---
#include <memory>

int callByValue(std::unique_ptr<int> a) { return *a; }  // comment me out - see
below
int callByRef(std::unique_ptr<int> && a) { return *a; }

int callItByRef(std::unique_ptr<int> a) {
  return callByRef(std::move(a));
}
---cut---

Compiled and output thus:
  g++ foo.cc -O2 -S -o - -g | c++filt | head -50

One can see that the final function "callItByRef" doesn't have a `.loc`
anywhere in it to tie it to the source.

At -O1 the locations are output correctly.

Interestingly, commenting out the (unused) callByValue function causes the
callItByRef to gain debug information, which makes me wonder if there's a bug
here rather than a difficulty in tracking debug information per se.

Reply via email to