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

sgk at troutmask dot apl.washington.edu gcc-bugzilla@gcc.gnu.org
Mon May 20 17:26:00 GMT 2019


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

--- Comment #12 from Steve Kargl <sgk at troutmask dot apl.washington.edu> ---
On Mon, May 20, 2019 at 03:06:32PM +0000, sgk at troutmask dot
apl.washington.edu wrote:
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90536
> 
> --- Comment #11 from Steve Kargl <sgk at troutmask dot apl.washington.edu> ---
> On Mon, May 20, 2019 at 07:32:09AM +0000, tkoenig at gcc dot gnu.org wrote:
> > 
> > what I meant is that
> > 
> > Program main
> >   Integer(kind=1) :: n
> >   n = 1
> > End
> > 
> > should not warn with -fno-range-check -Wall, and it does.
> > 
> 
> The warning technically is correct.  It is a warning about the
> type conversion not about the value.
> 

Upon further reflection, not only is gfortran's behavior
correct, it is desireable.

This PR should be closed as INVALID.  Why?

For the above code, neither 

gfortran -c -Wconversion a.f90

nor 

gfortran -c -Wconversion-extra a.f90

emit a warning because gfortran does range checking,
determines that the INTEGER(4) '1' on the RHS is within
range of an INTEGER(1) 'n' on the LHS when type conversion
is done, and so chooses to suppress a conversion warning.

When a user uses -fno-range-check, she/he is specifically
asking the compiler to not range check.  gfortran only knows
that the RHS is an INTEGER(1) entity and the LHS is an
INTEGER(4) entity.  It has no other information upon which
to make a decision of whether to emit a warning.  So, 
gfortran informs the user that a conversion occurs.  There
is no other information without range checking.


More information about the Gcc-bugs mailing list