隐蔽的数据溢出问题

unsigned int blocks = 20000;
unsigned int blocksize = 5000;
int64_t totalsize;

// overflow, error!!
totalsize = blocks * blocksize;

// mandatory type transfer, right!
totalsize = (int64_t)blocks * blocksize;

你可能感兴趣的:(数据)