Sorry. The previous is not the one causes the problem. Try this: struct S { string str = "Hello"; // Adding an initial value here. };
S g_s; unittest { S s1; S s2; assert(s1 == s2); // Success assert(g_s == s1); // Fail auto s3 = g_s; assert(s3 == g_s);; // Even this will fail. } It seems if the string is initialized with a default value, then this does not work.