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.