Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 588
Innocent Boy Avatar asked Nov 08 '10 04:11

Innocent Boy


1 Answers

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.

like image 180
James McNellis Avatar answered Sep 28 '22 06:09

James McNellis