This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug fortran/33544] Spurious warning in TRANSFER intrinsic in Sept 24 snapshot of gfortran
- From: "burnus at gcc dot gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 24 Sep 2007 19:17:54 -0000
- Subject: [Bug fortran/33544] Spurious warning in TRANSFER intrinsic in Sept 24 snapshot of gfortran
- References: <bug-33544-14284@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- 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