Consider the following program:
#include <iostream>
#include <ostream>
#include <string>
#include <utility>
using namespace std;
struct Name { string s; Name(string s) : s(move(s)) { } };
struct A : virtual Name { A(string s) : Name(move(s)) { } };
struct B : virtual Name { B(string s) : Name(move(s)) { } };
struct C : A, B { C(string s) : A(string()), B(string()), Name(move(s)) { } };
C f() { return C("abcdefghijklmnopqrstuvwxyz"); }
int main()
{
C c1("ABCDEFGHIJKLMNOPQRSTUVWXYZ");
C c2("ABCDEFGHIJKLMNOPQRSTUVWXYZ");
C ff = f();
c1 = f();
c2 = ff;
cout << "C1 = " << c1.s << " " << "C2 = " << c2.s << "\n";
return 0;
}
gcc (4.9.2) (http://ideone.com/G7uzCQ) and clang++ both print different values for C1 and C2 whereas Visual Studio 2013 and 2015 consistently print the lower case alphabet sequence for both C1 and C2.
Who is right? or is it just some loop hole in the standard?