This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: Walways-true:Warn if a comparison is always true or always false due to the limited range of the data type
- From: "Manuel López-Ibáñez" <lopezibanez at gmail dot com>
- To: "Rask Ingemann Lambertsen" <rask at sygehus dot dk>
- Cc: gcc-patches <gcc-patches at gcc dot gnu dot org>
- Date: Mon, 27 Aug 2007 11:23:51 +0100
- Subject: Re: Walways-true:Warn if a comparison is always true or always false due to the limited range of the data type
- References: <6c33472e0703040528x1b231f3freb9e1cbbb8e52082@mail.gmail.com> <20070826181904.GE25795@sygehus.dk>
On 26/08/07, Rask Ingemann Lambertsen <rask@sygehus.dk> wrote:
>
> Why do we get two different sets of warnings for the same thing in the
> first place?
First, to avoid confusion, let me say that the option is Wtype-limits
and not Walways-true. Second, the warnings were there already, I just
made them conditional on Wtype-limits.
Finally, you get two different warnings because the paths for widening
comparisons and for non-widening comparisons are different and (I
guess for historical reasons) do different things. The code is in
c-common.c (shorten_compare) and I guess it could do with a bit of
refactoring. I was not confident enough at the moment to try to clean
it up.
If you don't feel confident either to change it, perhaps you can
adjust the tests so they only match "is always true" or "is always
false".
Cheers,
Manuel.