2012-10-14 9:08:24
複製,粘貼,手誤,然後,重新定義了一個名字相同的局部變量,由於變量的作用域問題,返回了一個錯誤的值,導致嚴重錯誤!
void foo
{
BOOL ret = dosth1();
if (ret != 200)
{
BOOL ret = dosth2();
}
return ret;
}
2012-8-30 1:12:27
void demo(const char* pstr)
{
std::string path = pstr;
}
//在某個分支 pstr == NULL時崩潰
2012-8-29 修改數據結構版本V1,版本V2公用一個代碼倉庫的同一個工程,他們用到同一個頭文件,在修改版本V2的BUG的時候將結構體
struct demo{
char path[MAX_PATH];
}
改爲了 struct demo{
char path[MAX_PATH *2];
}
結果別的研發更新了版本V1的那個工程,重編,發佈之後,就出BUG了2012-7-19 變量初始化誤區int a, b =0;
do
{
b++;
} while (!a && b);
2012-7-19 數據類型不敏感
類型time_t 是64位8字節整數,故用"%d"錯誤,應該是"%I64d"
time_t t0 = time(NULL);
dosth1();
time_t t1 = time(NULL);
dosth1();
time_t t2 = time(NULL);
CString msg;
msg.Format("%d, %d, %d", t1-t0, t2-t1, t2-t0);
正確是應該是:
msg.Format("%I64d, %I64d, %I64d", t1-t0, t2-t1, t2-t0);