<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 - Variable not visible at Og"
href="https://bugs.llvm.org/show_bug.cgi?id=47273">47273</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Variable not visible 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>Variable l_5 should be visible in all the scope of func_1. However, when
executing line 9 it is not visible anymore.
$ cat -n a.c
1 int a;
2 char b;
3 char *c[2];
4 void func_1() {
5 int l_5 = 3, d = 0;
6 for (; d < 2; d++)
7 c[d] = b;
8 for (;;) {
9 if (l_5)
10 break;
11 a = &l_5;
12 __assert_fail();
13 }
14 }
15 int main() { func_1(); }
$ cat a.c
int a;
char b;
char *c[2];
void func_1() {
int l_5 = 3, d = 0;
for (; d < 2; d++)
c[d] = b;
for (;;) {
if (l_5)
break;
a = &l_5;
__assert_fail();
}
}
int main() { func_1(); }
$ clang -v
clang version 12.0.0 (<a href="https://github.com/llvm/llvm-project.git">https://github.com/llvm/llvm-project.git</a>
bc8be3054067ac822fc6d9f4f8e64c841f530f16)
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 opt
(lldb) target create "opt"
Current executable set to 'opt' (x86_64).
(lldb) b func_1
Breakpoint 1: where = opt`func_1 + 5 at a.c:5:7, address = 0x00000000004004e5
(lldb) r
Process 215 launched: 'opt' (x86_64)
Process 215 stopped
* thread #1, name = 'opt', stop reason = breakpoint 1.1
frame #0: 0x00000000004004e5 opt`func_1 at a.c:5:7
2 char b;
3 char *c[2];
4 void func_1() {
-> 5 int l_5 = 3, d = 0;
6 for (; d < 2; d++)
7 c[d] = b;
8 for (;;) {
(lldb) s
Process 215 stopped
* thread #1, name = 'opt', stop reason = step in
frame #0: 0x0000000000400500 opt`func_1 at a.c:7:10
4 void func_1() {
5 int l_5 = 3, d = 0;
6 for (; d < 2; d++)
-> 7 c[d] = b;
8 for (;;) {
9 if (l_5)
10 break;
(lldb) s
Process 215 stopped
* thread #1, name = 'opt', stop reason = step in
frame #0: 0x0000000000400507 opt`func_1 at a.c:6:12
3 char *c[2];
4 void func_1() {
5 int l_5 = 3, d = 0;
-> 6 for (; d < 2; d++)
7 c[d] = b;
8 for (;;) {
9 if (l_5)
(lldb) s
Process 215 stopped
* thread #1, name = 'opt', stop reason = step in
frame #0: 0x0000000000400500 opt`func_1 at a.c:7:10
4 void func_1() {
5 int l_5 = 3, d = 0;
6 for (; d < 2; d++)
-> 7 c[d] = b;
8 for (;;) {
9 if (l_5)
10 break;
(lldb) s
Process 215 stopped
* thread #1, name = 'opt', stop reason = step in
frame #0: 0x0000000000400507 opt`func_1 at a.c:6:12
3 char *c[2];
4 void func_1() {
5 int l_5 = 3, d = 0;
-> 6 for (; d < 2; d++)
7 c[d] = b;
8 for (;;) {
9 if (l_5)
(lldb) p l_5
(int) $0 = 3
(lldb) s
Process 215 stopped
* thread #1, name = 'opt', stop reason = step in
frame #0: 0x000000000040050d opt`func_1 at a.c:9:9
6 for (; d < 2; d++)
7 c[d] = b;
8 for (;;) {
-> 9 if (l_5)
10 break;
11 a = &l_5;
12 __assert_fail();
(lldb) p l_5
error: Couldn't materialize: couldn't get the value of variable l_5: variable
not available
error: errored out in DoExecute, couldn't PrepareToExecuteJITExpression</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>