[Bug fortran/90536] Spurious (?) warning when using -Wconversion with -fno-range-check

dominiq at lps dot ens.fr gcc-bugzilla@gcc.gnu.org
Mon May 20 09:22:00 GMT 2019


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

Dominique d'Humieres <dominiq at lps dot ens.fr> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|Use of -fno-range-check     |Spurious (?) warning when
                   |creates warnings or errors  |using -Wconversion with
                   |when assigning to a byte    |-fno-range-check
                   |variable                    |

--- Comment #10 from Dominique d'Humieres <dominiq at lps dot ens.fr> ---
The following test

        program test
        integer :: b1 = 2_8
        end

gives no warning when compiled with -Wconversion -Wconversion-extra:

% gfc pr90536_1_db.f90 -Wconversion -Wconversion-extra
%

but a warning when compiled with -Wconversion -fno-range-check:

% gfc pr90536_1_db.f90 -Wconversion -fno-range-check
pr90536_1_db.f90:2:23:

    2 |         integer :: b1 = 2_8
      |                       1
Warning: Conversion from 'INTEGER(8)' to 'INTEGER(4)' at (1) [-Wconversion]

I see in fortran/intrinsic.c

          /* Do nothing. Constants of the same type are range-checked
             elsewhere. If a value too large for the target type is
             assigned, an error is generated. Not checking here avoids
             duplications of warnings/errors.
             If range checking was disabled, but -Wconversion enabled,
             a non range checked warning is generated below.  */

So the behavior may be intended.


More information about the Gcc-bugs mailing list