Skip to main content

Posts

Showing posts from July, 2015

An Amazing recursion results in crash

A scenario, as per C++ specification supported and also supported by the GNU C++ compiler but not right to do so. Example: The following piece of code works both in the GNU C++ compiler as well as Microsoft C++ compiler. Code execution gives the right result (I mean expected output). #include  < vector > #include < iostream > class Simple { public: Simple(unsigned int aInt) : memberInteger(aInt) { } void Amaze() { myVector = { Simple(1), Simple(2) }; } unsigned int memberInteger; std::vector < Simple > myVector; }; int main() { Simple s(0); s.Amaze(); size_t sz = s.myVector.size(); return 0; } The size of my vector returns 2. Now, I've changed the a code little bit and it gets compiled well in Gnu C++ compiler(4.9.2 and used "g++ -std=c++11 -Wall Simple_Defeat.cpp -o Simple_Defeat" to compile) but not in Microsoft C++ compiler (Checked with 2013): #include < vector > #include < iostream &g