Jun 8, 2016 at 4:20am UTC
#include <iostream>
struct ChangeMemoryStructure
{
int x = 5;
};
struct Base
{
int id = 1;
};
struct Derived : public ChangeMemoryStructure, public Base
{
int whatever = 2;
};
void test0(Derived& obj, int Derived::*ptr)
{
int testing = obj.*ptr;
std::cout << (testing == 1);
}
void test1(Derived& obj, int Base::*ptr)
{
int testing = obj.*ptr;
std::cout << (testing == 1);
}
int main()
{
Derived obj;
test0(obj, &Base::id); //fails
test0(obj, &Derived::id); //fails
test1(obj, &Derived::id); //good
test1(obj, &Base::id); //good
return 0;
}
//I get 1111 on most compilers, but 0011 on VS2015 update 2.
Jun 8, 2016 at 4:54am UTC
Version issue? I get:
190023918 (version)
0011
Release/debug makes no difference
Last edited on Jun 8, 2016 at 4:54am UTC
Jun 8, 2016 at 5:10am UTC
I made a mistake: rextester is Visual Studio Update 1 _MSC_FULL_VER 190023506.
Your version _MSC_FULL_VER 190023918 is Visual Studio Update 2; I get 1111 with that too.
Have you installed the patch for Update2?
Jun 8, 2016 at 5:19am UTC
I just installed "Update 2" from the VS IDE. ATM if I go Tools -> 'extensions and updates' I can't see anything new there.
Jun 8, 2016 at 5:39am UTC
> I just installed "Update 2" from the VS IDE.
If it was just updated, the patch would be included in the update.
Hmm... I just did a clean and rebuild with Visual Studio Update 2, and got 0011 .
With the clang++ front-end, 'Clang with Microsoft CodeGen', I get 1111 .
(Note: The clang++ front-end ignores minor version numbers; it would report _MSC_FULL_VER as 190000000)
Appears to be a bug in the Microsoft front end.