键入不会导致精度损失的转换可能不会引发警告.它们是隐含的.
int --> double //no loss in precision (e.g 3 became 3.00)
double --> int //loss in precision (e.g. 3.01222 became 3)
触发警告的内容和不警告的内容在很大程度上取决于编译器和提供给它的标志,但是,大多数编译器(至少是我使用过的编译器)并不认为隐式类型转换非常危险,需要发出警告,因为它是语言规范中的一个特性.
警告或不警告:
C99理由表明它就像一条准则
One of the important outcomes of exploring this (implicit casting) problem is the understanding that high-quality compilers might do well to look
for such questionable code and offer (optional) diagnostics, and that
conscientious instructors might do well to warn programmers of the
problems of implicit type conversions.