Andrew Haley | 9 May 10:45 2009
Picon

Re: Disabling warning: suggest parentheses around && within ||

Andre Majorel wrote:
> Is there a way to have -Wall without all the
> "warning: suggest parentheses around && within ||" noise ?
> 

This is amazing.  I have only ever seen that warning on a few occasions,
and it's always been right.  I can't imagine what your code might look
like!

> -Wno-parentheses works, and seems to be supported at least as far
> back as GCC 2.95, but probably also disables other, potentially
> useful, warnings.

It doesn't.  I just looked at the gcc source, and -Wno-parentheses
only affects "suggest parentheses around X in Y" warnings.

Why don't you just put the parentheses in?  It's good advice.

Andrew.

Andre Majorel | 13 May 13:37 2009
Picon

Re: Disabling warning: suggest parentheses around && within ||

On 2009-05-09 09:45 +0100, Andrew Haley wrote:
> Andre Majorel wrote:
> > Is there a way to have -Wall without all the
> > "warning: suggest parentheses around && within ||" noise ?
> > -Wno-parentheses works, and seems to be supported at least as far
> > back as GCC 2.95, but probably also disables other, potentially
> > useful, warnings.
> 
> It doesn't.  I just looked at the gcc source, and -Wno-parentheses
> only affects "suggest parentheses around X in Y" warnings.

Meaning that it does. Some of those warnings are actually useful.

Thank you.

--

-- 
André Majorel <URL:http://www.teaser.fr/~amajorel/>

John (Eljay) Love-Jensen | 13 May 13:40 2009
Picon

RE: Disabling warning: suggest parentheses around && within ||

Hi Andre,

> Meaning that it does. Some of those warnings are actually useful.

If you want to remove "warning: suggest parentheses around && within ||" and keep any other "warning:
suggest parentheses around FOO within BAR" warnings, you can use grep -v -e to post process the output.

Or in your source, you can add in the parentheses, as suggested by the warning.

From your initial inquiry, it appeared that you wanted -Wall without any parentheses warnings (-Wno-parentheses).

Sincerely,
--Eljay

Andre Majorel | 13 May 15:45 2009
Picon

Re: Disabling warning: suggest parentheses around && within ||

On 2009-05-13 04:40 -0700, John (Eljay) Love-Jensen wrote:

> > Meaning that it does. Some of those warnings are actually useful.
> 
> If you want to remove "warning: suggest parentheses around &&
> within ||" and keep any other "warning: suggest parentheses
> around FOO within BAR" warnings, you can use grep -v -e to post
> process the output.

Which will only work in one locale. If GCC messages ever
acquire unique identifiers, it will be a welcome evolution.

Until then, the warnings are annoying but probably not annoying
enough for me to go to the trouble of making my makefiles so
GCC-specific.

Thank you.

--

-- 
André Majorel <URL:http://www.teaser.fr/~amajorel/>

Ian Lance Taylor | 13 May 16:39 2009
Picon

Re: Disabling warning: suggest parentheses around && within ||

Andre Majorel <aym-ccg <at> teaser.fr> writes:

> On 2009-05-13 04:40 -0700, John (Eljay) Love-Jensen wrote:
>
>> > Meaning that it does. Some of those warnings are actually useful.
>> 
>> If you want to remove "warning: suggest parentheses around &&
>> within ||" and keep any other "warning: suggest parentheses
>> around FOO within BAR" warnings, you can use grep -v -e to post
>> process the output.
>
> Which will only work in one locale. If GCC messages ever
> acquire unique identifiers, it will be a welcome evolution.

You can use -fdiagnostics-show-option to see which command line option
controls a particular warning.  You can use that as a locale-independent
identifier for this purpose.

> Until then, the warnings are annoying but probably not annoying
> enough for me to go to the trouble of making my makefiles so
> GCC-specific.

I've seen this specific warning, about the precedence of && and ||,
catch a surprising number of real errors in real code.  However, since
some people know the precedence of && and || just as well as they know
the precedence of + and *, I would be sympathetic to breaking them out
into a separate -Wparentheses-and-or warning.  Please feel free to file
that as an enhancement request at http://gcc.gnu.org/bugzilla .

Ian
(Continue reading)

Andrew Haley | 13 May 14:52 2009
Picon

Re: Disabling warning: suggest parentheses around && within ||

Andre Majorel wrote:
> On 2009-05-09 09:45 +0100, Andrew Haley wrote:
>> Andre Majorel wrote:
>>> Is there a way to have -Wall without all the
>>> "warning: suggest parentheses around && within ||" noise ?
>>> -Wno-parentheses works, and seems to be supported at least as far
>>> back as GCC 2.95, but probably also disables other, potentially
>>> useful, warnings.
>> It doesn't.  I just looked at the gcc source, and -Wno-parentheses
>> only affects "suggest parentheses around X in Y" warnings.
> 
> Meaning that it does. Some of those warnings are actually useful.

AFAIK all of them are.  You haven't explained why you like some of
them but not others.  As far as I can tell your complaint is wholly
arbitrary.

Andrew.


Gmane