https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99761
Bug ID: 99761 Summary: Warn flag for non-kind specified mixing Product: gcc Version: fortran-dev Status: UNCONFIRMED Severity: normal Priority: P3 Component: fortran Assignee: unassigned at gcc dot gnu.org Reporter: nickpapior at gmail dot com Target Milestone: --- Some context here: https://github.com/j3-fortran/fortran_proposals/issues/201 The basic message is that users may forget to add kind specifications for constants which are assigned to higher precision values which then loses the extra bits. Simplest example: real(8), parameter :: pi = 3.14159265358979323846 which actually only stores the floating point value and store that in a double precision variable, thereby loosing precision. My proposal would be to add a flag which warns about misused kinds: program test real(8), parameter :: const = 1.4435435345345 real(8), parameter :: const2 = 1./3. real(8), parameter :: const3 = 1._4/4._4 print *, 1./3. * const end program test it would be nice if the above could be compiled with gfortran -Wpedantic-kind and something like this would be issued: 2 | real(8), parameter :: const = 1.4435435345345 1 Warning: Constant expression at (1) is in lower precision than variable. 3 | real(8), parameter :: const2 = 1./3. 1 Warning: Constant expression at (1) is in lower precision than variable. 3 | real(8), parameter :: const2 = 1./3. 1 Warning: Constant expression at (1) is in lower precision than variable. 5 | print *, 1./3. * const 1 2 Warning: Constant at (1) has lower precision than variable at (2) Line 4 is silently ignored due to explicit kind specification. I think such an enhancement would be extremely useful to hunt down mis-typed kind specifiers.