I have a program:
#include<iostream> using namespace std; class Test { public: void func() { cout << "Inside func" << endl; throw; } }; int myfunc() { Test T; T.func(); return 1; } int main() { myfunc(); cout << "Main func" << endl;//should not print getchar(); }
I expected this program to end with main , but in VC ++ 2015, main cout is printed. This was against my understanding, so I compiled it with gcc and it works fine there.
Is this a bug in VC ++ 2015, or is the program termination behavior as unspecified / UB behavior? If he ever performed cout << "Main func" << endl; ?
IDE: VS2015 CTP Preview (within 30 days)
flags: /GS /analyze- /W3 /Zc:wchar_t /ZI /Gm /Od /sdl /Fd"Debug\vc140.pdb" /fp:precise /D "_MBCS" /errorReport:prompt /WX- /Zc:forScope /RTC1 /Gd /Oy- /MDd /Fa"Debug\" /EHsc /nologo /Fo"Debug\" /Fp"Debug\exception.pch"
source share