【发布时间】:2023-03-22 19:40:02
【问题描述】:
如何检测c++中unsigned char变量的溢出?
【问题讨论】:
-
首先,
unsigned char的范围是 0 到 255,而你已经分配了 260。 -
使用默认设置编译,gcc和g++会发出
warning: large integer implicitly truncated to unsigned type [-Woverflow]
标签: c++ char overflow unsigned