我使用Visual Studio 2005运行C++ Win32控制台应用程序时遇到了非常严重的错误.使用以下项目属性运行下面的代码(简化)时会出现问题:C++ | optimization | optimization |/O2(或/ O1,或/ Ox),C++ | optimization |整个程序优化|/GL,链接器|优化|/LTCG
#include "stdafx.h"
#include <iostream>
using namespace std;
const int MAXVAL=10;
class MyClass
{
private:
int p;
bool isGood;
public:
int SetUp(int val);
};
int MyClass::SetUp(int val)
{
isGood = true;
if (MAXVAL<val)
{
int wait;
cerr<<"ERROR, "<<MAXVAL<<"<"<<val<<endl;
cin>>wait;
//exit(1); //for x64 uncomment, for win32 leave commented
}
if (isGood) p=4;
return 1;
}
int _tmain(int argc, _TCHAR* argv[])
{
int wait=0, setupVal1=10, setupVal2=12;
MyClass classInstance1;
MyClass …Run Code Online (Sandbox Code Playgroud)