<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 hangs at -O3 on expression"
   href="http://llvm.org/bugs/show_bug.cgi?id=15714">15714</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>clang hangs at -O3 on expression
          </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 snippet (generated by csmith) causes top-of-trunk clang to get
stuck in an infinite loop at -O3 (-O2 and below are fine, as is clang 3.2). 
While it appears to invoke undefined behavior ((*d ^= 1 != (long)d)), hanging
is probably not the right thing to do.

$ clang-trunk -v
clang version 3.3 (trunk 179090)
Target: x86_64-pc-linux-gnu
Thread model: posix
$ clang-trunk -O2 -c test.c
$ clang-trunk -O3 -c test.c
<hangs>


int a, b, c;
int fn2();
void fn1 ()
{
    int *d, *e = &b;
    d = &b;
    *e = 0;
    c = 0;
    for (; c < 42; ++c)
    {
        (*d ^= 1 != (long)d) && fn2 ();
        if (a)
            break;
    }
}

int fn2 ()
{
    int *f = &b;
    *f = 1;
    return b;
}

void fn3 ()
{
    fn1 ();
}</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>