You refer to using gfortran 5.2.0, so let's look at the documentation for that version rather than 4.1.0. This has two relevant flags for what you consider:
-Wconversion
Warn about implicit conversions that are likely to change the
value of the expression after conversion. Implied by -Wall.
-Wconversion-extra
Warn about implicit conversions between different types and
kinds. This option does not imply -Wconversion.
If I use this latter flag with the following program
use, intrinsic :: iso_fortran_env, only : real32, real64
real(real64) x
x = 1._real32
end
I get exactly (albeit using gfortran 4.8.1) a warning message requested in the question title
Warning: Conversion from REAL(4) to REAL(8) at (1)
whereas with just -Wconversion
I get nothing. If I change the program slightly, however, so that the changing of representable values kicks in, I get (different) warnings with each.
ifort, on the other hand (up to 19.0.5), appears to have no comparable warning.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…