为什么 Clang 不为不兼容的转换生成任何警告?
Why Clang isn't generating any warnings for an incompatible casting?
我正在尝试用 gcc 和 clang 编译一个简单的 code。 gcc 为无与伦比的转换生成警告(太棒了!)。但是,clang 没有产生任何警告!我已经为两者传递了相同的参数:
cc -Wall -Wextra tmp3.c
gcc -Wall -Wextra tmp3.c
我是将所有必要的选项都传递给了 clang 编译器还是遗漏了什么? clang documentation 不是很好的帮助!
代码:
int main(void)
{
void *b = (void *)0x12345678;
int a = (int)(unsigned long)b;
int c = (int)b;
return a + c;
}
Clang 版本 3.8
我已经联系了 clang 开发人员(邮件列表)。我收到了这样的回复:
In C++ mode, Clang errors on the line, same as everyone else. In C
mode, however, conversions are typically more permissive. In this
case, I suspect Clang should generate this warning as well. It’ll
likely require a patch however.
我正在尝试用 gcc 和 clang 编译一个简单的 code。 gcc 为无与伦比的转换生成警告(太棒了!)。但是,clang 没有产生任何警告!我已经为两者传递了相同的参数:
cc -Wall -Wextra tmp3.c
gcc -Wall -Wextra tmp3.c
我是将所有必要的选项都传递给了 clang 编译器还是遗漏了什么? clang documentation 不是很好的帮助!
代码:
int main(void)
{
void *b = (void *)0x12345678;
int a = (int)(unsigned long)b;
int c = (int)b;
return a + c;
}
Clang 版本 3.8
我已经联系了 clang 开发人员(邮件列表)。我收到了这样的回复:
In C++ mode, Clang errors on the line, same as everyone else. In C mode, however, conversions are typically more permissive. In this case, I suspect Clang should generate this warning as well. It’ll likely require a patch however.