在64位和32位系统上运行程序。
在64位系统上完美运行的c ++程序在32位系统上崩溃时,有什么原因吗?我有一个在2个服务器上测试过的程序。一个是64位,另一个是32位。该程序没有位特定的命令。最初,它在两种情况下都起作用,直到我进行了修改并添加了一个结构并将其命名。第一次调用此结构对象时,程序崩溃。但是,如果我在崩溃之前打印元素1行的值,那么值就在那里。顺便说一句,按值是指整数,没有指针或其他有趣的东西。
我尝试将这些整数初始化为uint32_t和此类实验。但是遇到了死胡同。
结构是这样的
struct info {
int id1, id2;
string test;
};
map<string, info> allInfo
vector<string> temp;
/* temp populated */
info details = {atoi(temp[0].c_str()),atoi(temp[2].c_str()),temp[3].c_str()};
allInfo[temp[1].c_str()] = details;
/*somewhere after this it is accessed */
map<string, info>::iterator i;
/* printing the values here seems ok.. */
cout << (*i).second.id1 << endl << (*i).second.id2 << endl;
string first_id = \"idOne : \" + (*i).second.id1;
string second_id = \"idTwo: \" + (*i).second.id2;
没有找到相关结果
已邀请:
5 个回复
呕蹿尉
。 选项2:在各处添加打印语句,以准确确定段错误发生在此处的那一行(或尝试自行找出该行)。
徘廷
俺呵誓放胳
爆山
骂陋冠
可能是因为您的测试集有所不同,并且在非投掷系统上,您意外地获得了一个有效的地址来分配给字符串变量。