<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 Debug Information for Oz. Stepping on dead code."
   href="https://bugs.llvm.org/show_bug.cgi?id=45934">45934</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Wrong Debug Information for Oz. Stepping on dead code.
          </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>Keywords</th>
          <td>wrong-debug
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>enhancement
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>C
          </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>blitzrakete@gmail.com, dgregor@apple.com, ditaliano@apple.com, erik.pilkington@gmail.com, llvm-bugs@lists.llvm.org, richard-llvm@metafoo.co.uk
          </td>
        </tr></table>
      <p>
        <div>
        <pre>The debugger shows that line 2 is executed while it shouldn't be.

$ cat a.c
int add(int ui1, int ui2) {
  return ui1 + ui2;
}
int g_8 ;
int a = 4 ;
int c
 ;
int main()  {
  for (g_8 = 0; (g_8 < 49); g_8 = add(g_8, 9)) {
      for (; c ; c++)
        ;
    if (a)
      break;
  }
}

$ 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 -Oz -g -o opt a.c

$ lldb opt 
(lldb) target create "opt"
Current executable set to 'opt' (x86_64).
(lldb) b -l 2
Breakpoint 1: 2 locations.
(lldb) r
Process 145 launched: 'opt' (x86_64)
Process 145 stopped
* thread #1, name = 'opt', stop reason = breakpoint 1.2
    frame #0: 0x000000000040049d opt`main [inlined] add(ui1=0, ui2=9) at
a.c:2:14
   1    int add(int ui1, int ui2) {
-> 2      return ui1 + ui2;
   3    }
   4    int g_8 ;
   5    int a = 4 ;
   6    int c
   7     ;
(lldb) 

$ gdb opt
(gdb) b -l 2
Breakpoint 1 at 0x400474: -source a.c -line 2. (2 locations)
(gdb) r
Starting program: opt 

Breakpoint 1, main () at a.c:9
9         for (g_8 = 0; (g_8 < 49); g_8 = add(g_8, 9)) {
(gdb) s
add (ui1=0, ui2=9) at a.c:2
2         return ui1 + ui2;
(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>