*Ping* patch, fortran] Warn about constant integer divisions

Steve Kargl sgk@troutmask.apl.washington.edu
Wed Jun 24 23:22:00 GMT 2015


On Thu, Jun 25, 2015 at 12:21:24AM +0200, FX wrote:
> > In compiling LAPACK, there are few n*(n+1)/2 type warnings.
> > So, yes, it might produce an annoying warning.  So be it.
> 
> I don?t think the proposed warning belongs to -Wall at all,
> probably more like -Wextra.
> 
> The doc for -Wall says: ?warning options pertaining to usage that
> we recommend avoiding and that we believe are easy to avoid?. Do
> we consider integer division bad practice? I think there are cases
> where it?s actually good practice, such as the n*(n+1)/2 example
> mentionned. Moreover, it?s not easily avoided (defining another
> named constant with the numeric value? not really good practice
> if you ask me).
> 
> Adding ?borderline useful" warnings to -Wall just means people
> will use it less, decreases its value.
> 
> 
> FX

Perhaps, we then need to review what -Wall is/does, or
can we remove -Wmaybe-uninitialized and maybe -Wconversion
from -Wall?

Checking LAPACK with -O -Wall, I see

% grep -i "integer div" sgk.log | wc -l
      16
% grep -i "maybe-" sgk.log | wc -l
     623
% grep -i "complex(4) to real(4)" sgk.log | wc -l
      97
% grep -i "real(4) to integer(4)" sgk.log | wc -l
      40

Every warning I get with -Wmaybe-uninitialized and my code 
is a false positive.  In particular, I see things like

scat.f90:309:0: warning: 'barray.dim[0].ubound' may be used uninitialized
in this function [-Wmaybe-uninitialized]
       barray = 0
 ^
scat.f90:309:0: warning: 'barray.dim[0].lbound' may be used uninitialized
in this function [-Wmaybe-uninitialized]

where barray.dim[0].ubound is clearly a internally generated entity.
A normal user may be confused by such warnings.

-- 
Steve



More information about the Fortran mailing list