Why/how does the virtual-ness of a base class change the behaviour of the copy constructor?
c++, c++11
Solution
Your problem looks similar to the one reported as a bug here in the official bugzilla for the llvm project.
As you can see is a recognized bug and it's been patched in the newer versions of Clang, you should switch to newer version of the frontend to fix this issue; in the bug report is also specified the exact revision of clang that is offering a patch for this issue.
Problem
I dont understand the behaviour of this snippet: (compiled with clang++ 3.0) ``` #include <iostream> using namespace std; class Base { public: virtual void bar() {} bool foo = false; }; class Derived : public Base{ public: Derived() { Base::foo = true; } }; int main() { Derived d; Base b(d); cout << b.foo << endl; // prints 0 // prints 1 if "virtual void bar() {}" is removed } ``` Why does the function Base::bar() have any effect on the copying of Base::foo ?