このコードが実行時エラーになるのですが、仕様でしょうか?
環境は、VC++ visualstudio2017です。
コード:
#include <iostream>
#include <string>
using namespace std;
class A
{
public:
A() {};
~A() {};
std::string str1;
union { std::string str2; };
};
int main() {
A a;
a.str1 = "Hello";
a.str2 = a.str1;
}
最後の代入のところでエラーになります。