'this' pointer is not corrected when calling method imported from base class by a 'using' declaration - by Zbyl

Status : 


Sign in
to vote
ID 804654 Comments
Status Closed Workarounds
Type Bug Repros 2
Opened 10/5/2013 9:34:15 AM
Access Restriction Public


In some very specific cases 'this' pointer is not appropriately corrected when calling a method from one of the base classes.

This happens when the following conditions are all met at the same time:
- using multiple inheritance,
- importing a method from a base class with the 'using' declaration,
- the imported method has a 'const' version in the base class,
- calling imported method using it's name qualified by the class name.

This bug happens in both unoptimized and optimized builds.

I've attached a minimal reproduction program.
This program outputs "2" when compiled using VC 10 (Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 16.00.40219.01 for 80x86), which is a correct result.
But it outputs "1" when compiled using VC 12 RC (Microsoft (R) C/C++ Optimizing Compiler Version 18.00.20827.3 for x86) or the 64 bit version (Microsoft (R) C/C++ Optimizing Compiler Version 18.00.20827.3 for x64), which is an incorrect result.

Changing any of the conditions mentioned above causes the program to output a correct value:
- removing 'using' declaration avoids the bug,
- removing the 'const' version of the 'get' method avoids the bug,
- removing 'C::' qualification avoids the bug,
- changing 'C::' qualification to "B::" avoids the bug.

This bug affects for example the LLVM/clang project. Clang compiler compiled using VC 12 RC is completely broken because of this bug.
Sign in to post a comment.
Posted by Xiang [MSFT] on 12/8/2013 at 1:14 PM
    Thanks for reporting the issue.
    A fix for this issue has been checked into the compiler sources. The fix should show up in future release of Visual C++.

Xiang Fan
Visual C++ Team
Posted by Macy [MSFT] on 10/7/2013 at 2:32 AM
Thanks for your feedback.

We are rerouting this issue to the appropriate group within the Visual Studio Product Team for triage and resolution. These specialized experts will follow-up with your issue.
Posted by srscode on 10/5/2013 at 12:19 PM
I can verify that this is the case, and that gcc also produces the expected output "2" for the test case.
Posted by Macy [MSFT] on 10/5/2013 at 9:53 AM
Thank you for your feedback, we are currently reviewing the issue you have submitted. If this issue is urgent, please contact support directly(http://support.microsoft.com)