<html>
    <head>
      <base href="http://llvm.org/bugs/" />
    </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 --- - clang produces incorrect code with loop/expression at -O2"
   href="http://llvm.org/bugs/show_bug.cgi?id=16130">16130</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>clang produces incorrect code with loop/expression at -O2
          </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>normal
          </td>
        </tr>

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

        <tr>
          <th>Component</th>
          <td>LLVM Codegen
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>dhazeghi@yahoo.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvmbugs@cs.uiuc.edu
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>The following testcase produces incorrect results when compiled with current
clang trunk at -O2 or above on x86_64-linux-gnu.  clang 3.2 does not have this
behavior.

$ clang-trunk -v
clang version 3.4 (trunk 182568)
Target: x86_64-pc-linux-gnu
Thread model: posix
$ clang-trunk -Os wrong.c 
$ ./a.out 
8
$ clang-3.2 -O2 wrong.c 
$ ./a.out 
8
$ clang-trunk -O3 wrong.c 
$ ./a.out 
0
$
----------------------------
int printf (const char *, ...);
int a;
int
fn1 ()
{
    int b = 0;
    for (; b != 13; b =b+8)
            if ((a = b)) return 1;
    return 0;
}

int
main ()
{
    int c = fn1 ();
    printf ("%d\n", a);
    return 0;
}</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>