C++ 这颗钻石是MinGW的一只虫子吗? #包括 #包括 类VeryBase{ 受保护的: INTA_; 公众: VeryBase():a_u1{} 虚拟运算符std::string(){ 返回“0”; } }; Base1类:公共虚拟VeryBase{ 受保护的: int b_; 公众: Base1():b_2;(2){} 运算符std::string(){ 返回“1”; } }; Base2类:公共虚拟VeryBase{ 受保护的: 国际货币基金组织; 公众: Base2():c_3{} 运算符std::string(){ 返回“2”; } }; 类TargetClass:public Base1、public Base2{ 受保护的: int d_; 公众: TargetClass():d_4{} 运算符std::string(){ std::ostringstream s; 这看起来像是一个编译器错误(或运行时支持dynamic\u cast的错误)。虽然我没有仔细研究,但代码看起来是正确的。当然,除非发布的代码不是产生问题的代码。

C++ 这颗钻石是MinGW的一只虫子吗? #包括 #包括 类VeryBase{ 受保护的: INTA_; 公众: VeryBase():a_u1{} 虚拟运算符std::string(){ 返回“0”; } }; Base1类:公共虚拟VeryBase{ 受保护的: int b_; 公众: Base1():b_2;(2){} 运算符std::string(){ 返回“1”; } }; Base2类:公共虚拟VeryBase{ 受保护的: 国际货币基金组织; 公众: Base2():c_3{} 运算符std::string(){ 返回“2”; } }; 类TargetClass:public Base1、public Base2{ 受保护的: int d_; 公众: TargetClass():d_4{} 运算符std::string(){ std::ostringstream s; 这看起来像是一个编译器错误(或运行时支持dynamic\u cast的错误)。虽然我没有仔细研究,但代码看起来是正确的。当然,除非发布的代码不是产生问题的代码。,c++,windows,mingw,diamond-problem,C++,Windows,Mingw,Diamond Problem,我刚刚用以下代码进行了测试: 32位和64位MinGW-w64 GCC 4.6/4.7/4.8版本 MSVC 11.0和MSVC 11.0 11月CTP 使用GCC4.6libstdc的32位Clang 3.2++ 全部在Windows上,并且全部提供输出: 1 2 3 4 1 2 3 4 1 2 3 4 这与Linux上的Clang和GCC相同 这是否是未定义的行为,我不确定。从未使用过dynamic\u cast这是mingw gcc的已知问题 不要使用虚拟继承,问题就会消失 Bugt

我刚刚用以下代码进行了测试:

  • 32位和64位MinGW-w64 GCC 4.6/4.7/4.8版本
  • MSVC 11.0和MSVC 11.0 11月CTP
  • 使用GCC4.6libstdc的32位Clang 3.2++
全部在Windows上,并且全部提供输出:

1 2 3 4
1 2 3 4
1 2 3 4
这与Linux上的Clang和GCC相同


这是否是未定义的行为,我不确定。从未使用过
dynamic\u cast

这是mingw gcc的已知问题

不要使用虚拟继承,问题就会消失


Bugtracker

“未定义的行为”是语言定义中的一个技术术语。它仅表示语言定义没有说明发生了什么。如果在运行代码时看到奇怪的事情发生,则不一定“显示未定义的行为”.正式地说,代码需要在顶部的某个位置包含。这可能与问题无关。谢谢。我想知道我的Qt软件包是否有损坏的版本。我想是这个: