<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 does not throw away unused dynamic_cast"
   href="http://llvm.org/bugs/show_bug.cgi?id=16136">16136</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>clang does not throw away unused dynamic_cast
          </td>
        </tr>

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

        <tr>
          <th>Version</th>
          <td>3.2
          </td>
        </tr>

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

        <tr>
          <th>OS</th>
          <td>All
          </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>C++
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>yozh@mx1.ru
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>dgregor@apple.com, llvmbugs@cs.uiuc.edu
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Code:

===
struct aaa { virtual ~aaa() {} } ;

struct bbb : public aaa {};

void foo(aaa* aaa) {
    dynamic_cast<bbb*>(aaa);
}
===

GCC -O3 produces code:

===
0000000000000000 <_Z3fooP3aaa>:
   0:    f3 c3                    repz retq
===

Clang 3.2 -O3:

===
0000000000000000 <_Z3fooP3aaa>:
   0:    48 85 ff                 test   %rdi,%rdi
   3:    74 16                    je     1b <_Z3fooP3aaa+0x1b>
   5:    be 00 00 00 00           mov    $0x0,%esi
   a:    ba 00 00 00 00           mov    $0x0,%edx
   f:    48 c7 c1 ff ff ff ff     mov    $0xffffffffffffffff,%rcx
  16:    e9 00 00 00 00           jmpq   1b <_Z3fooP3aaa+0x1b>
  1b:    c3                       retq
===

So it looks like clang does not throw dynamic_cast away, when result of
dynamic_cast is unused.</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>