Do Ideone and Codepad really not support C++03?

My question is related to Prasoon's question about non POD types and value initialization.

I tried the following code on online compilers like Ideone and Codepad but the executables gave runtime error on both the sites.

#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 Output here
Codepad Output here

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


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

Yes.

Prior to version 4.4, GCC did not completely support value initialization (the Boost GCC compatibility header explains this and has links to the relevant GCC defect reports; see line 77).

If your code needs to be portable, you should be very careful relying on value initialization; GCC did not support it fully until recently and Visual C++ does not fully support it even in its latest version, Visual C++ 2010.


The declaration

InStruct i; 

does not invoke value initialization

$8.5.3/10 - "An object whose initializer is an empty set of parentheses, ie, (), shall be value-initialized."

If you want to value-initialize, you would require an expression something like

assert(InStruct().Int == 0);

Try it now! - Ideone supports GCC-4.5.1

链接地址: http://www.djcxy.com/p/48756.html

上一篇: 根据字体堆栈中使用的字体来调整字体大小

下一篇: Ideone和Codepad确实不支持C ++ 03吗?