g ++可以检测到丢失的重要位吗?
int main()
{
unsigned long l = 0x123456789abcd;
unsigned int i = 0x12345678;
unsigned short s1 = l;
unsigned short s2 = i;
return (s1 + s2);
}
g++ -Wall -Wextra foo.cpp
// 没有警告
gcc 版本 4.4.6
g ++可以检测到丢失的重要位吗?
int main()
{
unsigned long l = 0x123456789abcd;
unsigned int i = 0x12345678;
unsigned short s1 = l;
unsigned short s2 = i;
return (s1 + s2);
}
g++ -Wall -Wextra foo.cpp
// 没有警告
gcc 版本 4.4.6
尽管名称明确,但“-Wall”并未启用所有警告。'-Wconversion' 将通知您截断转换。见http://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html