<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=45923">45923</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Wrong variable value shown during debugging at Og
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>clang
          </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>-New Bugs
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedclangbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>massarelli@diag.uniroma1.it
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>ditaliano@apple.com, htmldeveloper@gmail.com, llvm-bugs@lists.llvm.org, neeilans@live.com, richard-llvm@metafoo.co.uk
          </td>
        </tr></table>
      <p>
        <div>
        <pre>At line 13 value 1 should be assigned to variable f while -1 is shown in lldb
and gdb.

$ cat a.c
typedef unsigned uint32_t;
int(a)(b) { return b; }
char c;
uint32_t d;
static int func_5(uint32_t p_6) {
  for (; c; c = 5)
    p_6 || d;
}
int e;
int main() {
  int f;
  e = a(8);
  f = e && 9;
  func_5(f);
}

$ clang -v
clang version 11.0.0 (<a href="https://github.com/llvm/llvm-project.git">https://github.com/llvm/llvm-project.git</a>
c25b20c0f6c13d68dbc2e185764082d61ae4a132)
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
Found candidate GCC installation:
/usr/local/bin/../lib/gcc/x86_64-pc-linux-gnu/11.0.0
Selected GCC installation: /usr/local/bin/../lib/gcc/x86_64-pc-linux-gnu/11.0.0
Candidate multilib: .;@m64
Selected multilib: .;@m64

$ lldb -v
lldb version 11.0.0
  clang revision c25b20c0f6c13d68dbc2e185764082d61ae4a132
  llvm revision c25b20c0f6c13d68dbc2e185764082d61ae4a132

$ gdb -v
GNU gdb (Ubuntu 8.1-0ubuntu3.2) 8.1.0.20180409-git

$ clang -O3 -g -o opt a.c

$ lldb opt
(lldb) target create "opt"
Current executable set to 'opt' (x86_64).
(lldb) b main
Breakpoint 1: where = opt`main at a.c:12:5, address = 0x0000000000400490
(lldb) r
Process 117 launched: 'opt' (x86_64)
Process 117 stopped
* thread #1, name = 'opt', stop reason = breakpoint 1.1
    frame #0: 0x0000000000400490 opt`main at a.c:12:5
   9    int e;
   10   int main() {
   11     int f;
-> 12     e = a(8);
   13     f = e && 9;
   14     func_5(f);
   15   }
(lldb) n
Process 117 stopped
* thread #1, name = 'opt', stop reason = step over
    frame #0: 0x000000000040049a opt`main at a.c:14
   11     int f;
   12     e = a(8);
   13     f = e && 9;
-> 14     func_5(f);
   15   }
(lldb) p f
(int) $0 = -1
(lldb) p e 
(int) $1 = 8
(lldb) expr e && 8
(bool) $2 = true

$ gdb opt
(gdb) b main
Breakpoint 1 at 0x400490: file a.c, line 12.
(gdb) r
Starting program: opt 

Breakpoint 1, main () at a.c:12
12        e = a(8);
(gdb) s
14        func_5(f);
(gdb) p f
$1 = -1
(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>