This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Implement warning for wrong use of ||/&&


On 12/02/07, Dirk Mueller <dmueller@suse.de> wrote:
On Tuesday, 13. February 2007 00:20, Manuel López-Ibáñez wrote:

> No, please, don't do this. Walways-true warnings have nothing to do
> with this (the name is wrong wrong wrong, this is the same mistake
> that was done with Wconversion, but worse because this time the
> description of Walways-true is also wrong, so please let's not repeat
> it again).

Well, the description of -Walways-true is certainly suboptimal, yes, because
it references to an example that certainly does not trigger
under -Walways-true. However, I think it is the one that comes closest to the
spirit of it. If you can suggest a new name, I'm perfectly fine with adding
yet another warning option for this one. I was just saying that it is low
false-positive and therefore imho doesn't hurt to be in -Wall.


The description of Walways-true is: Warn about comparisons which are always true such as testing if unsigned values are greater than or equal to zero.

Walways-true was introduced to warn for (and it only does this so far):

bool func(void);
[...]
if (func) { return x;} /* warning */

suboptimal is ... uhm ... well, ok, let's say suboptimal then. ;-)

> PS: I think there are already warnings for wrong usage of || and &&
> somewhere. If you don't want to bother, I would like the patch to be
> hold until I can look them up.

Sure, please have a look. The only thing that comes to my mind
is -Wparentheses warning about expressions which include || and && without
explicit precedence.


Thanks. I will have a look at this as soon as I have time.


Cheers,

Manuel.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]