[LLVMbugs] [Bug 20116] New: Miscompilation when devirtualization is aborted due to covariant return types

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Tue Jun 24 07:32:22 PDT 2014


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

            Bug ID: 20116
           Summary: Miscompilation when devirtualization is aborted due to
                    covariant return types
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: LLVM Codegen
          Assignee: unassignedclangbugs at nondot.org
          Reporter: izbyshev at ispras.ru
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified

Created attachment 12699
  --> http://llvm.org/bugs/attachment.cgi?id=12699&action=edit
A failing test case

When compiling the attached code, clang doesn't emit 'this' adjustment code for
'static_cast<A*>(z)' expression and ends up using a wrong vtable for the
virtual call. As a result, B.g() is called instead of Z.f().

Inspection of CodeGenFunction::EmitCXXMemberCallExpr() code shows that clang
can stop devirtualization in the middle if it finds out that return types are
covariant. At that moment, 'Base' expression that is later used for emission of
'this' pointer has already been assigned to 'Inner' expression (with casts
stripped), so no 'this' adjustment code is generated.

-- 
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/20140624/10cb9ed2/attachment.html>


More information about the llvm-bugs mailing list