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);