<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 - Wrong variable value shown during debugging at Og"
href="https://bugs.llvm.org/show_bug.cgi?id=46191">46191</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Wrong variable value shown during debugging at Og
</td>
</tr>
<tr>
<th>Product</th>
<td>libraries
</td>
</tr>
<tr>
<th>Version</th>
<td>trunk
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>Linux
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>enhancement
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>DebugInfo
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>massarelli@diag.uniroma1.it
</td>
</tr>
<tr>
<th>CC</th>
<td>jdevlieghere@apple.com, keith.walker@arm.com, llvm-bugs@lists.llvm.org, paul_robinson@playstation.sony.com
</td>
</tr></table>
<p>
<div>
<pre>At the second iteration of the for loop at line 9, a wrong value is shown for
variable p_24. The same behaviour is visible with gdb.
$ cat -n a.c
1 typedef int int32_t;
2 int32_t g, m;
3 short h, i, j, k, l;
4 char n;
5 long(a)(b, c) { return b + c; }
6 char(d)(e, f) { return e - f; }
7 void func_20(int32_t p_24) {
8 h = 0;
9 for (; h < 6; h = a(h, 3)) {
10 int32_t a = k = 1 != p_24;
11 i &= g;
12 m |= a;
13 l++;
14 n = d(g, a);
15 }
16 }
17 int main() { func_20(j); }
$ cat a.c
typedef int int32_t;
int32_t g, m;
short h, i, j, k, l;
char n;
long(a)(b, c) { return b + c; }
char(d)(e, f) { return e - f; }
void func_20(int32_t p_24) {
h = 0;
for (; h < 6; h = a(h, 3)) {
int32_t a = k = 1 != p_24;
i &= g;
m |= a;
l++;
n = d(g, a);
}
}
int main() { func_20(j); }
$ clang -v
clang version 11.0.0 (<a href="https://github.com/llvm/llvm-project.git">https://github.com/llvm/llvm-project.git</a>
d4ef654673a921878ba5aedb9725b2ac32681f01)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /usr/local/bin
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/7
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/7.5.0
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/8
Selected GCC installation: /usr/lib/gcc/x86_64-linux-gnu/7.5.0
Candidate multilib: .;@m64
Selected multilib: .;@m64
$ lldb -v
lldb version 11.0.0
clang revision d4ef654673a921878ba5aedb9725b2ac32681f01
llvm revision d4ef654673a921878ba5aedb9725b2ac32681f01
$ gdb -v
GNU gdb (Ubuntu 8.1-0ubuntu3.2) 8.1.0.20180409-git
$ clang -Og -g -o opt a.c
$ ldb opt
(lldb) target create "opt"
Current executable set to 'opt' (x86_64).
(lldb) b -l 9
Breakpoint 1: where = opt`func_20 + 89 at a.c:9:23, address =
0x00000000004004f9
(lldb) c
error: invalid process
(lldb) r
Process 346 launched: 'opt' (x86_64)
Process 346 stopped
* thread #1, name = 'opt', stop reason = breakpoint 1.1
frame #0: 0x00000000004004f9 opt`func_20(p_24=0) at a.c:9:23
6 char(d)(e, f) { return e - f; }
7 void func_20(int32_t p_24) {
8 h = 0;
-> 9 for (; h < 6; h = a(h, 3)) {
10 int32_t a = k = 1 != p_24;
11 i &= g;
12 m |= a;
(lldb) c
Process 346 resuming
Process 346 stopped
* thread #1, name = 'opt', stop reason = breakpoint 1.1
frame #0: 0x00000000004004f9 opt`func_20(p_24=0) at a.c:9:23
6 char(d)(e, f) { return e - f; }
7 void func_20(int32_t p_24) {
8 h = 0;
-> 9 for (; h < 6; h = a(h, 3)) {
10 int32_t a = k = 1 != p_24;
11 i &= g;
12 m |= a;
(lldb) s
Process 346 stopped
* thread #1, name = 'opt', stop reason = step in
frame #0: 0x0000000000400480 opt`a(b=3, c=3) at a.c:5:26
2 int32_t g, m;
3 short h, i, j, k, l;
4 char n;
-> 5 long(a)(b, c) { return b + c; }
6 char(d)(e, f) { return e - f; }
7 void func_20(int32_t p_24) {
8 h = 0;
(lldb) s
Process 346 stopped
* thread #1, name = 'opt', stop reason = step in
frame #0: 0x0000000000400507 opt`func_20(p_24=0) at a.c:9:21
6 char(d)(e, f) { return e - f; }
7 void func_20(int32_t p_24) {
8 h = 0;
-> 9 for (; h < 6; h = a(h, 3)) {
10 int32_t a = k = 1 != p_24;
11 i &= g;
12 m |= a;
(lldb) s
Process 346 stopped
* thread #1, name = 'opt', stop reason = step in
frame #0: 0x0000000000400492 opt`d(e=0, f=1) at a.c:6:26
3 short h, i, j, k, l;
4 char n;
5 long(a)(b, c) { return b + c; }
-> 6 char(d)(e, f) { return e - f; }
7 void func_20(int32_t p_24) {
8 h = 0;
9 for (; h < 6; h = a(h, 3)) {
(lldb) s
Process 346 stopped
* thread #1, name = 'opt', stop reason = step in
frame #0: 0x000000000040052e opt`func_20(p_24=1) at a.c:10:19
7 void func_20(int32_t p_24) {
8 h = 0;
9 for (; h < 6; h = a(h, 3)) {
-> 10 int32_t a = k = 1 != p_24;
11 i &= g;
12 m |= a;
13 l++;
$ gdb opt
(gdb) b -l 9
Breakpoint 1 at 0x4004f9: file a.c, line 9.
(gdb) r
Starting program: /home/stepping/output/opt
Breakpoint 1, func_20 (p_24=0) at a.c:9
9 for (; h < 6; h = a(h, 3)) {
(gdb) c
Continuing.
Breakpoint 1, func_20 (p_24=0) at a.c:9
9 for (; h < 6; h = a(h, 3)) {
(gdb) s
a (b=3, c=c@entry=3) at a.c:5
5 long(a)(b, c) { return b + c; }
(gdb) s
d (e=e@entry=0, f=f@entry=1) at a.c:6
6 char(d)(e, f) { return e - f; }
(gdb) s
func_20 (p_24=1) at a.c:10
10 int32_t a = k = 1 != p_24;
(gdb)</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are on the CC list for the bug.</li>
</ul>
</body>
</html>