This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: C/C++ PATCH for c/77423 (bogus warning with -Wlogical-not-parentheses)
On 09/05/16 17:00, Eric Gallager wrote:
> On 9/5/16, Bernd Edlinger <bernd.edlinger@hotmail.de> wrote:
>> On 09/05/16 14:03, Marek Polacek wrote:
>>> On Fri, Sep 02, 2016 at 03:51:49PM +0000, 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 certainly agree that the warning is compeletely misleading here:
>>
>> test.c: In function 'f':
>> test.c:10:11: warning: logical not is only applied to the left hand side
>> of comparison [-Wlogical-not-parentheses]
>> r += !a == ~b;
>> ^~
>> 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 mean ! ?
>>
>
>
> The exclamation mark followed by question mark looks kind of confusing
> to me; it looks too much like punctuation (instead of an operator).
> Maybe quote it or spell it out?
> i.e.
> warning: '~' on boolean value, did you mean '!' ?
> or
> warning: tilde used to negate boolean value, did you mean to use an
> exclamation mark to negate it instead?
>
>
Yes, thanks good point.
Bernd.