[C++ PATCH]: warning on implicit float->int

N8TM@aol.com N8TM@aol.com
Mon Feb 28 07:27:00 GMT 2000


>In developing this code, I wrote 1.0 and
-1.0 instead of real(1.0) and real(-1.0), and ended up doing a lot of
the arithmetic in double instead of float, as I intended.  This code
happened to be C++, but the same issues would apply to C.

If we follow this road, then there will be a warning for any implicit
conversions, which may be what is wanted in some cases.
<<

Maybe I don't understand.  We Fortran people do get confused by the difference between Fortran, where 1.0 is a REAL (float) constant, same as 1.0f in C,  and C or C++, where 1.0 is a double constant, same as 1.0D0 in Fortran.  Fortran now permits the safer tack of setting up a scheme where 1.0_RL could be set to be whatever is needed, but there would be no warning if you forgot and used 1.0 alone. But we do have an obligation to deal with the situation as it stands.   Even if such warnings are limited to constant propagation, they could prove quite tiresome for correctly written code.


More information about the Gcc-patches mailing list