Re: C/C++ PATCH for c/77423 (bogus warning with -Wlogical-not-parentheses)

2016-09-16 Thread Marek Polacek
On Thu, Sep 15, 2016 at 01:21:21PM -0600, Jeff Law wrote: > On 09/05/2016 08:28 AM, Marek Polacek wrote: > > > test.c:10:8: note: add parentheses around left hand side expression to > > > silence this warning > > > r += !a == ~b; > > > ^~ > > > ( ) > > > > > > this will not f

Re: C/C++ PATCH for c/77423 (bogus warning with -Wlogical-not-parentheses)

2016-09-15 Thread Jeff Law
On 09/05/2016 08:28 AM, Marek Polacek wrote: test.c:10:8: note: add parentheses around left hand side expression to silence this warning r += !a == ~b; ^~ ( ) this will not fix it, but make it worse. I think a better warning would be warning: ~ on boolean value, did you me

Re: C/C++ PATCH for c/77423 (bogus warning with -Wlogical-not-parentheses)

2016-09-06 Thread Marek Polacek
On Mon, Sep 05, 2016 at 10:35:26AM -0600, Sandra Loosemore wrote: > On 09/05/2016 09:55 AM, Bernd Schmidt wrote: > > > > > > On 09/05/2016 12:52 PM, Marek Polacek wrote: > > > On Mon, Sep 05, 2016 at 12:35:13PM +0200, Bernd Schmidt wrote: > > > > On 09/02/2016 05:13 PM, Marek Polacek wrote: > > >

Re: C/C++ PATCH for c/77423 (bogus warning with -Wlogical-not-parentheses)

2016-09-05 Thread Bernd Edlinger
On 09/05/16 18:45, Joseph Myers wrote: > On Mon, 5 Sep 2016, Marek Polacek wrote: > >> Still not sure about other operations. I guess no one would >> object to warning on bool1 % bool2, but should we warn for >> bool1 + bool2? > > I think boolean addition (with the result interpreted as an integer

Re: C/C++ PATCH for c/77423 (bogus warning with -Wlogical-not-parentheses)

2016-09-05 Thread Joseph Myers
On Mon, 5 Sep 2016, Marek Polacek wrote: > Still not sure about other operations. I guess no one would > object to warning on bool1 % bool2, but should we warn for > bool1 + bool2? I think boolean addition (with the result interpreted as an integer, not converted back to boolean) is perfectly r

Re: C/C++ PATCH for c/77423 (bogus warning with -Wlogical-not-parentheses)

2016-09-05 Thread Sandra Loosemore
On 09/05/2016 09:55 AM, Bernd Schmidt wrote: On 09/05/2016 12:52 PM, Marek Polacek wrote: On Mon, Sep 05, 2016 at 12:35:13PM +0200, Bernd Schmidt wrote: On 09/02/2016 05:13 PM, Marek Polacek wrote: diff --git gcc/doc/invoke.texi gcc/doc/invoke.texi index 87da1f1..38d55d4 100644 --- gcc/doc/i

Re: C/C++ PATCH for c/77423 (bogus warning with -Wlogical-not-parentheses)

2016-09-05 Thread Bernd Schmidt
On 09/05/2016 12:52 PM, Marek Polacek wrote: On Mon, Sep 05, 2016 at 12:35:13PM +0200, Bernd Schmidt wrote: On 09/02/2016 05:13 PM, Marek Polacek wrote: diff --git gcc/doc/invoke.texi gcc/doc/invoke.texi index 87da1f1..38d55d4 100644 --- gcc/doc/invoke.texi +++ gcc/doc/invoke.texi @@ -5437,8

Re: C/C++ PATCH for c/77423 (bogus warning with -Wlogical-not-parentheses)

2016-09-05 Thread Bernd Edlinger
On 09/05/16 17:00, Eric Gallager wrote: > On 9/5/16, Bernd Edlinger wrote: >> On 09/05/16 14:03, Marek Polacek wrote: >>> On Fri, Sep 02, 2016 at 03:51:49PM +, Bernd Edlinger wrote: Hi, > + r += !a == ~b; > + r += !a == ~(int) b; I don't understand why ~b

Re: C/C++ PATCH for c/77423 (bogus warning with -Wlogical-not-parentheses)

2016-09-05 Thread Bernd Edlinger
On 09/05/16 16:28, Marek Polacek wrote: > On Mon, Sep 05, 2016 at 02:08:20PM +, Bernd Edlinger wrote: >> On 09/05/16 14:03, Marek Polacek wrote: >>> On Fri, Sep 02, 2016 at 03:51:49PM +, Bernd Edlinger wrote: Hi, > + r += !a == ~b; > + r += !a == ~(int) b; >

Re: C/C++ PATCH for c/77423 (bogus warning with -Wlogical-not-parentheses)

2016-09-05 Thread Eric Gallager
On 9/5/16, Bernd Edlinger wrote: > On 09/05/16 14:03, Marek Polacek wrote: >> On Fri, Sep 02, 2016 at 03:51:49PM +, Bernd Edlinger wrote: >>> Hi, >>> >>> > + r += !a == ~b; >>> > + r += !a == ~(int) b; >>> >>> I don't understand why ~b should not be warned at -Wall. >> >> Yeah, there was

Re: C/C++ PATCH for c/77423 (bogus warning with -Wlogical-not-parentheses)

2016-09-05 Thread Marek Polacek
On Mon, Sep 05, 2016 at 02:08:20PM +, Bernd Edlinger wrote: > On 09/05/16 14:03, Marek Polacek wrote: > > On Fri, Sep 02, 2016 at 03:51:49PM +, Bernd Edlinger wrote: > >> Hi, > >> > >> > + r += !a == ~b; > >> > + r += !a == ~(int) b; > >> > >> I don't understand why ~b should not be w

Re: C/C++ PATCH for c/77423 (bogus warning with -Wlogical-not-parentheses)

2016-09-05 Thread Bernd Edlinger
On 09/05/16 14:03, Marek Polacek wrote: > On Fri, Sep 02, 2016 at 03:51:49PM +, Bernd Edlinger wrote: >> Hi, >> >> > + r += !a == ~b; >> > + r += !a == ~(int) b; >> >> I don't understand why ~b should not be warned at -Wall. > > Yeah, there was an RFE for this but I'm not finding it. > I

Re: C/C++ PATCH for c/77423 (bogus warning with -Wlogical-not-parentheses)

2016-09-05 Thread Marek Polacek
On Fri, Sep 02, 2016 at 03:51:49PM +, Bernd Edlinger wrote: > Hi, > > > + r += !a == ~b; > > + r += !a == ~(int) b; > > I don't understand why ~b should not be warned at -Wall. Yeah, there was an RFE for this but I'm not finding it. > Frankly I don't even understand why the above state

Re: C/C++ PATCH for c/77423 (bogus warning with -Wlogical-not-parentheses)

2016-09-05 Thread Marek Polacek
On Mon, Sep 05, 2016 at 12:35:13PM +0200, Bernd Schmidt wrote: > On 09/02/2016 05:13 PM, Marek Polacek wrote: > > diff --git gcc/doc/invoke.texi gcc/doc/invoke.texi > > index 87da1f1..38d55d4 100644 > > --- gcc/doc/invoke.texi > > +++ gcc/doc/invoke.texi > > @@ -5437,8 +5437,8 @@ if (a < 0 && a < 0

Re: C/C++ PATCH for c/77423 (bogus warning with -Wlogical-not-parentheses)

2016-09-05 Thread Bernd Schmidt
On 09/02/2016 05:13 PM, Marek Polacek wrote: diff --git gcc/doc/invoke.texi gcc/doc/invoke.texi index 87da1f1..38d55d4 100644 --- gcc/doc/invoke.texi +++ gcc/doc/invoke.texi @@ -5437,8 +5437,8 @@ if (a < 0 && a < 0) @{ @dots{} @} @opindex Wlogical-not-parentheses @opindex Wno-logical-not-parent

Re: C/C++ PATCH for c/77423 (bogus warning with -Wlogical-not-parentheses)

2016-09-02 Thread Bernd Edlinger
Hi, > + r += !a == ~b; > + r += !a == ~(int) b; I don't understand why ~b should not be warned at -Wall. Frankly I don't even understand why the above statements are completely optimized away. r += !a == ~b; is optimized away, but b = ~b; r += !a == b; Is not. Why? Bernd.

C/C++ PATCH for c/77423 (bogus warning with -Wlogical-not-parentheses)

2016-09-02 Thread Marek Polacek
Martin reported that -Wlogical-not-parentheses issues a bogus warning for bit operations on booleans, because the warning didn't take integer promotions into account. The following patch ought to fix this problem. It's not exactly trivial because I had to handle even more complex expressions and