[LLVMbugs] [Bug 16136] New: clang does not throw away unused dynamic_cast

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Fri May 24 06:44:09 PDT 2013


http://llvm.org/bugs/show_bug.cgi?id=16136

            Bug ID: 16136
           Summary: clang does not throw away unused dynamic_cast
           Product: clang
           Version: 3.2
          Hardware: PC
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++
          Assignee: unassignedclangbugs at nondot.org
          Reporter: yozh at mx1.ru
                CC: dgregor at apple.com, llvmbugs at cs.uiuc.edu
    Classification: Unclassified

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.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20130524/dda97950/attachment.html>


More information about the llvm-bugs mailing list