This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PING] 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: "Gabriel Dos Reis" <gdr at cs dot tamu dot edu>
- Cc: gcc-patches at gcc dot gnu dot org, "Gabriel Dos Reis" <gdr at integrable-solutions dot net>
- Date: Thu, 5 Apr 2007 12:08:52 +0100
- Subject: Re: [PING] 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> <6c33472e0703211804h470315dar3ce4380325ea7f45@mail.gmail.com> <200703221038.51568.dmueller@suse.de> <6c33472e0703220304v60ece2adtcaf25f766c2cb30f@mail.gmail.com> <87fy7gdwke.fsf@soliton.cs.tamu.edu>
On 04 Apr 2007 09:49:05 -0500, Gabriel Dos Reis <gdr@cs.tamu.edu> wrote:
"Manuel López-Ibáñez" <lopezibanez@gmail.com> writes:
| On 22/03/07, Dirk Mueller <dmueller@suse.de> wrote:
| > On Thursday, 22. March 2007, Manuel López-Ibáñez wrote:
| >
| > > I think that after 18 days, a ping is due.
| > > PING: http://gcc.gnu.org/ml/gcc-patches/2007-03/msg00207.html
| >
| > Again my usual comment: I think -Walways-true is a bad name for a warning that
| > warns about expressions being always false.
| >
| > I think -Wlogical or -Wlogical-invariant or similar would be a better name.
| >
|
| I agree that it is a bad name but not because of the reason you point.
| I think it is bad because this warning should not try to warn about
| anything else than conditions that are always true (or false) because
| of the limited
| range of the data type. What you are trying to detect is whether you
| are using the wrong type in a comparison (or perhaps the wrong
| variable). In that context, Walways-true (and Wlogical) are too vague
| names but I prefer the former since Wlogical is even vaguer.
|
| Alternative names:
-Wtautology?
-Wunsigned-rel?
I think I forgot to put the emphasis in the proper place: conditions
that are always true (or false) *because of the limited range of the
data type*.
-Wtautology
You may have a tautology in a logical expression, like if (1 == 1) or
something like if (!x || x), but this warning should not handle those.
-Wunsigned-rel
Again, this is not neccesarily about just unsigned. I think shorts and
enums are handled by the warning as well.
Don't you like Wtype-bounds or Wtype-range? I am feeling already
biased. I think it would be great to be able to get some feedback from
users. Like:
How do you think that the option that produces this message:
"condition is always true because of the limited range of the data type"
is called?
[ ] Wtautology
[ ] Wtype-range
[ ] Wtype-bounds
[ ] Wunsigned-rel
[ ] Wlogical-op
Other: [ ]
Perhaps we could send this to gcc-help or some user list...
Please, send me links to other patches I've not formally reviewed --
use my address at integrable-solutions.net; they have again messed up
mails here. :-(
http://gcc.gnu.org/ml/gcc-patches/2007-03/msg01435.html
http://gcc.gnu.org/ml/gcc-patches/2007-02/msg01102.html
And if you had some time, it would be very helpful to get some
feedback from you about the thread here
http://gcc.gnu.org/ml/gcc-patches/2007-03/msg00171.html. The patch is
useful for the C front-end as it is and I think it is useful as well
for the C++ front-end despite it doesn't warn for anonymous
namespaces. But I don't think I can solve that since it is an
orthogonal issue. See the thread for more info.
Thanks,
Manuel.