[lldb-dev] [Bug 35654] New: LLDB Does not print the correct value for a variable (suspect NRVO alias issue)

via lldb-dev lldb-dev at lists.llvm.org
Wed Dec 13 15:02:31 PST 2017


https://bugs.llvm.org/show_bug.cgi?id=35654

            Bug ID: 35654
           Summary: LLDB Does not print the correct value for a variable
                    (suspect NRVO alias issue)
           Product: lldb
           Version: unspecified
          Hardware: Macintosh
                OS: MacOS X
            Status: NEW
          Severity: normal
          Priority: P
         Component: All Bugs
          Assignee: lldb-dev at lists.llvm.org
          Reporter: chris.m.hartman at gmail.com
                CC: llvm-bugs at lists.llvm.org

macbookpro:BugReport hartman$ clang++ --version
Apple LLVM version 9.0.0 (clang-900.0.39.2)
Target: x86_64-apple-darwin17.3.0
Thread model: posix
InstalledDir:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
macbookpro:BugReport hartman$ lldb --version
lldb-900.0.64
  Swift-4.0
macbookpro:BugReport hartman$ cat main.cpp
void bar2(){};

struct Large
{
    int a,b,c,d,e;
};

Large f2()
{
    bar2();
    Large r;
    r.a=1;
    int s=r.a;
    return r;
}

int main() {
    f2();
    return 0;
}

macbookpro:BugReport hartman$ clang++ --debug main.cpp
macbookpro:BugReport hartman$ lldb ./a.out
(lldb) target create "./a.out"
Current executable set to './a.out' (x86_64).
(lldb) breakpoint set --file main.cpp --line 14
Breakpoint 1: where = a.out`f2() + 39 at main.cpp:14, address =
0x0000000100000f77
(lldb) run
Process 70299 launched: './a.out' (x86_64)
Process 70299 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = breakpoint 1.1
    frame #0: 0x0000000100000f77 a.out`f2() at main.cpp:14
   11       Large r;
   12       r.a=1;
   13       int s=r.a;
-> 14       return r;
   15   }
   16   
   17   int main() {
Target 0: (a.out) stopped.
(lldb) print s
(int) $0 = 1
(lldb) print r.a
(int) $1 = -272631496
(lldb) print r
(Large) $2 = (a = -272631496, b = 32766, c = -272631496, d = 32766, e = 0)

With a breakpoint at line 14 ("return r;") LLDB does not print the correct
value for r, although s shows the correct value. This seems to be highly
sensitive: r must be of large size (apparently anything bigger than 4 ints),
the return value, and declared after a call to some other function, which makes
me suspect some interaction with NRVO. If the call to bar() is commented out,
things work just fine.

-- 
You are receiving this mail because:
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/lldb-dev/attachments/20171213/42f72f48/attachment.html>


More information about the lldb-dev mailing list