<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 --- - missed dead code elimination, linker error"
   href="http://llvm.org/bugs/show_bug.cgi?id=17882">17882</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>missed dead code elimination, linker error
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>clang
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>3.3
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>FreeBSD
          </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>-New Bugs
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>andreast@gcc.gnu.org
          </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 below test case fails to link with clang. gcc48 does work.


-----
extern void dead(void);

void test(int x)
{
        if (x || 1)
                return;
        dead();
}

int main()
{
        test(0);
        return 0;
}
-----

When I change the if (x||1) to if(1||x) the compile/link succeeds.

Here the output of the failing test:

[tcx58:~] andreast% clang -o dead dead.c
/tmp/dead-hllbPY.o: In function `test':
dead.c:(.text+0x2d): undefined reference to `dead'
clang: error: linker command failed with exit code 1 (use -v to see invocation)

The original code was discovered in qemu-trunk, the workaround is to change the
if condition.

The credit for the test case and the workaround goes to Paolo Bonzini.

I have tested this on FreeBSD -CURRENT:

[tcx58:~] andreast% clang -v
FreeBSD clang version 3.3 (tags/RELEASE_33/final 183502) 20130610
Target: x86_64-unknown-freebsd11.0
Thread model: posix</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>