您的位置:首页 > 编程语言 > C语言/C++

貌似是微软编译器的一个Bug

2013-09-06 11:46 295 查看
有如下代码:

#include <stdio.h>
int my_func(void)
{
/* float f = 0.0; */
return(0.0 ? 1 : 0);
}
int main(void)
{
printf("%s\n", ( my_func() ? "ONE" : "NIL") );
return 0;
}


在vc6.0和vs2010中运行,你能说出它的输出结果吗?

答案:ONE

以上代码在gcc中确是不同的结果。。。

或许是微软编译器的一个bug吧,求解释!

参考资料:

[1].http://stackoverflow.com/questions/18008126/floating-point-constant-comparison-0-0-1-0

[2].http://ideone.com/8qPRJd
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息