[Bug fortran/33544] Spurious warning in TRANSFER intrinsic in Sept 24 snapshot of gfortran

burnus at gcc dot gnu dot org gcc-bugzilla@gcc.gnu.org
Mon Sep 24 19:18:00 GMT 2007



------- Comment #4 from burnus at gcc dot gnu dot org  2007-09-24 19:17 -------
> We may want to hide the warning behind a -Wshort-transfer option
> (or some other appropriate name).
Maybe; I think having a warning by default would be more reasonable but it
should be hideable.

> Afterall, if a programmer wrote 'rft = transfer(' ', 0.0)',
> then s/he probably meant it.

I sincerely doubt that the programmer meant that this piece of code produces
different results depending on the compiler and possibly some random value in
memory. For the given example, many compilers seem to initialize the result
with zero; example:

PROGRAM printd
REAL :: rft
rft = TRANSFER(' ', 0.0)
print *, rft
rft = TRANSFER(' '//achar(0)//achar(0)//achar(0), 0.0)
print *, rft
END PROGRAM printd

The second transfer produces: 4.4841551E-44
g95, ifort and openf95 seem to produce the same result also for the first
TRANSFER.
gfortran, NAG f95 and sunf95 have, however, a different result every time.

Thus, if one wants to argue that the programmer intended a certain value, I
would argue that it is the one using a zero-padded SOURCE.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33544



More information about the Gcc-bugs mailing list