This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: *Ping* patch, fortran] Warn about constant integer divisions
- From: Janne Blomqvist <blomqvist dot janne at gmail dot com>
- To: Thomas Koenig <tkoenig at netcologne dot de>
- Cc: "fortran at gcc dot gnu dot org" <fortran at gcc dot gnu dot org>, gcc-patches <gcc-patches at gcc dot gnu dot org>
- Date: Tue, 23 Jun 2015 11:36:05 +0300
- Subject: Re: *Ping* patch, fortran] Warn about constant integer divisions
- Authentication-results: sourceware.org; auth=none
- References: <557C3F76 dot 2000901 at netcologne dot de> <5586C2DB dot 3080600 at netcologne dot de>
On Sun, Jun 21, 2015 at 4:57 PM, Thomas Koenig <tkoenig@netcologne.de> wrote:
> *ping*
>
> https://gcc.gnu.org/ml/gcc-patches/2015-06/msg00966.html
>
>
>> Hello world,
>>
>> the attached patch emits a warning for constant integer division.
>> While correct according to the standard, I cannot really think
>> of a legitimate reason why people would want to write 3/5 where
>> they could have written 0 , so my preference would be to put
>> this under -Wconversion (like in the attached patch).
>>
>> However, I am open to discussion on that. It is easy enough to
>> change.
>>
>> Regression-tested. Opinions? Comments? Would somebody rather
>> have -Wconversion-extra? OK for trunk?
I'm a bit uncomfortable about this. IIRC I have code where I'm
iterating over some kind of grid, and I'm using integer division and
relying on truncation to calculate array indices. I can certainly
imagine that others have used it as well, and even that it's not a
particularly uncommon pattern.
Furthermore, I think it's confusing that you have it under
-Wconversion, as there is no type conversion going on.
-Winteger-truncation maybe?
Any other opinions?
--
Janne Blomqvist