snprintf in write_float.def
Tobias Schlüter
tobias.schlueter@physik.uni-muenchen.de
Sun May 11 11:57:00 GMT 2008
FX wrote:
> While reducing PR36200, I was looking at libgfortran/io/write_float.def,
> and after having refreshed my memory about printf formats, it seems to
> me that what we're doing in DTOA and DTOAL is unsafe: the "e" format
> expects an argument of type double, and yet when used for real(kind=4),
> we'll happily pass it a "float". So, am I overlooking something or
> should we apply the patch below (which casts values to "double" or "long
> double")? I suspect there is more to it that I saw, because we'd see a
> large number of failures otherwise. So, comments welcome.
floats passed as varargs are automatically casted to double. E.g.:
$ cat t.c
void a(int i, ...);
void b() { float f = 1.; a(1,f); }
$ gcc -c t.c -fdump-tree-generic
$ cat t.c.t03.generic
b ()
{
double D.1463;
float f;
f = 1.0e+0;
D.1463 = (double) f;
a (1, D.1463);
}
$
Regards,
- Tobi
More information about the Fortran
mailing list