<html>
<head>
<base href="https://bugs.llvm.org/">
</head>
<body><table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Bug ID</th>
<td><a class="bz_bug_link
bz_status_NEW "
title="NEW - LLDB Does not print the correct value for a variable (suspect NRVO alias issue)"
href="https://bugs.llvm.org/show_bug.cgi?id=35654">35654</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>LLDB Does not print the correct value for a variable (suspect NRVO alias issue)
</td>
</tr>
<tr>
<th>Product</th>
<td>lldb
</td>
</tr>
<tr>
<th>Version</th>
<td>unspecified
</td>
</tr>
<tr>
<th>Hardware</th>
<td>Macintosh
</td>
</tr>
<tr>
<th>OS</th>
<td>MacOS X
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>normal
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>All Bugs
</td>
</tr>
<tr>
<th>Assignee</th>
<td>lldb-dev@lists.llvm.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>chris.m.hartman@gmail.com
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org
</td>
</tr></table>
<p>
<div>
<pre>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.</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are the assignee for the bug.</li>
</ul>
</body>
</html>