为什么将double赋值给int不会触发gcc警告? [英] Why assignment of double to int does not trigger gcc warnings?

查看:348
本文介绍了为什么将double赋值给int不会触发gcc警告?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  int i = 3.1 / 2 

不会导致任何警告,即使有-Wall选项。有时,我想知道在哪里精确度会丢失。为什么gcc不支持这个警告,而msvc支持这个?



谢谢。



编辑:我的gcc -v显示

配置为:../ ../gcc-4.4.1/configure --prefix = / mingw --build = mingw32 --enable-languages = c,ada,c ++,fortran,objc,obj-c ++ --disable -nls --disable-win32 -enable-cxx-flags =' - fno-function-sections -fno-data-sections'--disable-werror --enable-threads --disable-symvers --enable-version- specific-runtime-libs --enable-fully-dynamic-string --with-pkgversion ='TDM-2 mingw32'--enable-sjlj-exceptions --with-bugurl = http://www.tdragon.net/recentgcc / bugs.php

解决方案

b

int i = 3.1 / 2

does not cause any warnings,even with -Wall option.Sometimes,I would like to know where precision lose.Why gcc does not support this warning,while msvc support this one?

thanks.

EDIT: my gcc -v shows

Configured with: ../../gcc-4.4.1/configure --prefix=/mingw --build=mingw32 --enable-languages=c,ada,c++,fortran,objc,obj-c++ --disable-nls --disable-win32-registry --enable-libgomp --enable-cxx-flags='-fno-function-sections -fno-data-sections' --disable-werror --enable-threads --disable-symvers --enable-version-specific-runtime-libs --enable-fully-dynamic-string --with-pkgversion='TDM-2 mingw32' --enable-sjlj-exceptions --with-bugurl=http://www.tdragon.net/recentgcc/bugs.php

解决方案

-Wconversion warns for implicit conversion.

这篇关于为什么将double赋值给int不会触发gcc警告?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆