[Bug fortran/91497] -Wconversion warns when doing explicit type conversion

manfred99 at gmx dot ch gcc-bugzilla@gcc.gnu.org
Thu Sep 12 00:10:00 GMT 2019


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91497

--- Comment #14 from Manfred Schwarb <manfred99 at gmx dot ch> ---
>FWIW, I briefly looked at conversions of complex variables
>and did not find any similar -Wconversion warnings for a patched compiler.

Well, I only looked at REAL,REALPART,AIMAG,IMAG,IMAGPART,DIMAG.

For CMPLX, there is some warning:

      complex(4) ww
      complex(8) xx

      ww=CMPLX(1.0_8, 1.0_8)
      ww=CMPLX(1.0_8, 1.0_8, kind=4)
      ww=COMPLEX(1.0_8, 1.0_8)
      xx=CMPLX(1.0_10, 1.0_10)
      xx=CMPLX(1.0_10, 1.0_10, kind=8)
      xx=COMPLEX(1.0_10, 1.0_10)
      end

c.f:4:15:

    4 |       ww=CMPLX(1.0_8, 1.0_8)
      |               1
Warning: Conversion from REAL(8) to default-kind COMPLEX(4) at (1) might lose
precision, consider using the KIND argument [-Wconversion]
c.f:7:15:

    7 |       xx=CMPLX(1.0_10, 1.0_10)
      |               1
Warning: Conversion from REAL(10) to default-kind COMPLEX(4) at (1) might lose
precision, consider using the KIND argument [-Wconversion]


This seems very reasonable though, no warnings when using an
explicit kind statement.
So no action needed here, from my point of view.


More information about the Gcc-bugs mailing list