From: Jeff Law <law@redhat.com>
To: Marek Polacek <polacek@redhat.com>,
Bernd Edlinger <bernd.edlinger@hotmail.de>
Cc: Joseph Myers <joseph@codesourcery.com>,
"gcc-patches@gcc.gnu.org" <gcc-patches@gcc.gnu.org>
Subject: Re: C/C++ PATCH for c/77423 (bogus warning with -Wlogical-not-parentheses)
Date: Thu, 15 Sep 2016 19:55:00 -0000 [thread overview]
Message-ID: <8a0aa578-654f-2cc9-535a-af961c800e2a@redhat.com> (raw)
In-Reply-To: <20160905142850.GD19950@redhat.com>
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 mean ! ?
>
> Could you please open a PR? I'll take care of it.
>
> Still not sure about other operations. I guess no one would
> object to warning on bool1 % bool2, but should we warn for
> bool1 + bool2?
Wouldn't the desire for a warning largely depend on the type of the
result? So I'll assume you're referring to a boolean result :-)
bool1 + bool2 does have meaning though, even when the result is a bool.
You have to be leery of both having a true value as that causes an overflow.
Jeff
next prev parent reply other threads:[~2016-09-15 19:21 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-09-02 15:51 Bernd Edlinger
2016-09-05 14:08 ` Marek Polacek
2016-09-05 14:28 ` Bernd Edlinger
2016-09-05 14:39 ` Marek Polacek
2016-09-05 15:03 ` Bernd Edlinger
2016-09-05 16:46 ` Joseph Myers
2016-09-05 17:03 ` Bernd Edlinger
2016-09-15 19:55 ` Jeff Law [this message]
2016-09-16 9:05 ` Marek Polacek
2016-09-05 15:01 ` Eric Gallager
2016-09-05 15:08 ` Bernd Edlinger
-- strict thread matches above, loose matches on Subject: below --
2016-09-02 15:14 Marek Polacek
2016-09-05 10:51 ` Bernd Schmidt
2016-09-05 10:57 ` Marek Polacek
2016-09-05 16:12 ` Bernd Schmidt
2016-09-05 16:44 ` Sandra Loosemore
2016-09-06 9:08 ` Marek Polacek
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=8a0aa578-654f-2cc9-535a-af961c800e2a@redhat.com \
--to=law@redhat.com \
--cc=bernd.edlinger@hotmail.de \
--cc=gcc-patches@gcc.gnu.org \
--cc=joseph@codesourcery.com \
--cc=polacek@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).