You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
The text was updated successfully, but these errors were encountered:
llvmbot
transferred this issue from llvm/llvm-bugzilla-archive
Dec 9, 2021
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.
The text was updated successfully, but these errors were encountered: