c++ - Ideone和Codepad真的不支持C++03吗?

标签 c++ value-initialization codepad

我的问题与Prasoon有关的question关于非 POD 类型和值初始化。

我在 Ideone 和 Codepad 等在线编译器上尝试了以下代码,但可执行文件在这两个站点上都出现了运行时错误。

#include <iostream>
#include <cassert>

struct Struct {
    std::string String;
    int Int;
    bool k;
};

struct InStruct:Struct
{
   InStruct():Struct(){}
};

int main()
{
   InStruct i;
   assert ( i.Int == 0);
   std::cout << "Hello";
}

Ideone 输出 here
键盘输出 here

这是否意味着它们都不支持 C++03 值初始化功能?

最佳答案

Does that mean neither of them support C++03 value initialization feature?

是的。

在版本 4.4 之前,GCC 不完全支持值初始化(the Boost GCC compatibility header 对此进行了解释,并提供了相关 GCC 缺陷报告的链接;请参阅第 77 行)。

如果您的代码需要可移植,那么您应该非常小心地依赖值初始化; GCC 直到最近才完全支持它,而 Visual C++ 即使在其最新版本 Visual C++ 2010 中也没有完全支持它。

关于c++ - Ideone和Codepad真的不支持C++03吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4121296/

相关文章:

c++ - boost::multiprecision 比较两个 cpp_int 值

c++ - 通过 r 值引用接收后通过引用传递

c++ - 为什么虚拟表中有两个虚拟析构函数,非虚拟函数的地址在哪里(gcc4.6.3)

c++ - 为什么 libstdc++ 为迭代器上的二元运算符实现 <L,R> 和 <LR> 重载?

c++ - 用作初始值设定项时,空括号 (“T()” ) 和空大括号 (“T{}” ) 有什么区别吗?

perl - codepad.org 的 Perl 运行程序限制是什么?

c++ - 输入迭代器的值初始化

c++ - 自动变量的值初始化

d - 打不通你好,世界计划工作