Do Ideone and Codepad not support C ++ 03?

My question is related to the Prasoon question about non-POD types and value initialization.

I tried the following code for online compilers such as Ideone and Codepad, but the executables displayed a runtime error on both 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 exit here
Codepad Output here

Does this mean that none of them supports the C ++ 03 value initialization function?

+7
c ++ value-initialization codepad
source share
3 answers

Does this mean that none of them supports the C ++ 03 value initialization function?

Yes.

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

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

+4
source share

Announcement

 InStruct i; 

does not cause value initialization

$ 8.5.3 / 10 - "The Object, Initializer is an empty set of brackets, that is (), the Value must be initialized."

If you want to initialize a value, you need an expression like

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

Try it now! - Ideal supports GCC-4.5.1

0
source share

All Articles