Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Miscompilation when devirtualization is aborted due to covariant return types #20490

Closed
llvmbot opened this issue Jun 24, 2014 · 0 comments
Closed
Labels
bugzilla Issues migrated from bugzilla clang:codegen

Comments

@llvmbot
Copy link
Collaborator

llvmbot commented Jun 24, 2014

Bugzilla Link 20116
Resolution FIXED
Resolved on Sep 30, 2014 04:08
Version trunk
OS Linux
Attachments A failing test case
Reporter LLVM Bugzilla Contributor
CC @alexey-bataev,@majnemer,@hfinkel,@rnk,@irishrover

Extended Description

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.

@llvmbot llvmbot transferred this issue from llvm/llvm-bugzilla-archive Dec 9, 2021
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugzilla Issues migrated from bugzilla clang:codegen
Projects
None yet
Development

No branches or pull requests

1 participant