*Ping* patch, fortran] Warn about constant integer divisions
FX
fxcoudert@gmail.com
Wed Jun 24 22:21:00 GMT 2015
Reading the thread, and in particular this:
>> Thomas, please following Janne's suggestion of adding a new
>> -W option (I'll suggest -Winteger-division) and add this
>> to -Wall.
>
> After following this discussion, I think this is what makes the most
> sense.
and this:
> i = 4 / 2
> 1
> Warning: Integer division simplifies to constant '2' at (1) [-Wconversion]
> a.f90:9:7:
>
> 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
More information about the Fortran
mailing list