public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/65120] New: [gcc5] Wlogical-not-parentheses should not wanr about double exclamation !!
@ 2015-02-19 13:39 jirislaby at gmail dot com
2015-02-19 13:41 ` [Bug c/65120] [5 Regression] Wlogical-not-parentheses should not warn " rguenth at gcc dot gnu.org
` (12 more replies)
0 siblings, 13 replies; 14+ messages in thread
From: jirislaby at gmail dot com @ 2015-02-19 13:39 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65120
Bug ID: 65120
Summary: [gcc5] Wlogical-not-parentheses should not wanr about
double exclamation !!
Product: gcc
Version: 5.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
Assignee: unassigned at gcc dot gnu.org
Reporter: jirislaby at gmail dot com
While warning about
"if (!a == b)"
is perfectly fine and I like it, I do not like warning about
"if (!!a = b)"
at all. It generates plenty of false positives (in the Linux kernel at least)
and I doubt it can warn about an error at all.
Better than papering over this as
"if ((!aa) = b)"
or by -Wno-logical-not-parentheses does not make much sense to me (opposing to
the single ! case).
Note: this is all about:
"logical not is only applied to the left hand side of comparison"
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug c/65120] [5 Regression] Wlogical-not-parentheses should not warn about double exclamation !!
2015-02-19 13:39 [Bug c/65120] New: [gcc5] Wlogical-not-parentheses should not wanr about double exclamation !! jirislaby at gmail dot com
@ 2015-02-19 13:41 ` rguenth at gcc dot gnu.org
2015-02-19 13:41 ` [Bug c/65120] [gcc5] " jirislaby at gmail dot com
` (11 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: rguenth at gcc dot gnu.org @ 2015-02-19 13:41 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65120
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |diagnostic
Status|UNCONFIRMED |NEW
Last reconfirmed| |2015-02-19
Known to work| |4.9.2
Target Milestone|--- |5.0
Summary|[gcc5] |[5 Regression]
|Wlogical-not-parentheses |Wlogical-not-parentheses
|should not warn about |should not warn about
|double exclamation !! |double exclamation !!
Ever confirmed|0 |1
--- Comment #2 from Richard Biener <rguenth at gcc dot gnu.org> ---
testcase you can compile and which warns with -Wall
int a, b;
int main()
{
if (!!a == b)
return 1;
return 0;
}
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug c/65120] [gcc5] Wlogical-not-parentheses should not warn about double exclamation !!
2015-02-19 13:39 [Bug c/65120] New: [gcc5] Wlogical-not-parentheses should not wanr about double exclamation !! jirislaby at gmail dot com
2015-02-19 13:41 ` [Bug c/65120] [5 Regression] Wlogical-not-parentheses should not warn " rguenth at gcc dot gnu.org
@ 2015-02-19 13:41 ` jirislaby at gmail dot com
2015-02-19 13:42 ` [Bug c/65120] [5 Regression] " rguenth at gcc dot gnu.org
` (10 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: jirislaby at gmail dot com @ 2015-02-19 13:41 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65120
--- Comment #1 from Jiri Slaby <jirislaby at gmail dot com> ---
(In reply to Jiri Slaby from comment #0)
> Better than papering over this as
> "if ((!aa) = b)"
Pardon me, it should write:
"if ((!!aa) = b)"
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug c/65120] [5 Regression] Wlogical-not-parentheses should not warn about double exclamation !!
2015-02-19 13:39 [Bug c/65120] New: [gcc5] Wlogical-not-parentheses should not wanr about double exclamation !! jirislaby at gmail dot com
2015-02-19 13:41 ` [Bug c/65120] [5 Regression] Wlogical-not-parentheses should not warn " rguenth at gcc dot gnu.org
2015-02-19 13:41 ` [Bug c/65120] [gcc5] " jirislaby at gmail dot com
@ 2015-02-19 13:42 ` rguenth at gcc dot gnu.org
2015-02-19 13:49 ` rguenth at gcc dot gnu.org
` (9 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: rguenth at gcc dot gnu.org @ 2015-02-19 13:42 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65120
--- Comment #3 from Richard Biener <rguenth at gcc dot gnu.org> ---
And yes, the required
if ((!!a) == b)
is totally fugly.
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug c/65120] [5 Regression] Wlogical-not-parentheses should not warn about double exclamation !!
2015-02-19 13:39 [Bug c/65120] New: [gcc5] Wlogical-not-parentheses should not wanr about double exclamation !! jirislaby at gmail dot com
` (2 preceding siblings ...)
2015-02-19 13:42 ` [Bug c/65120] [5 Regression] " rguenth at gcc dot gnu.org
@ 2015-02-19 13:49 ` rguenth at gcc dot gnu.org
2015-02-19 14:48 ` jakub at gcc dot gnu.org
` (8 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: rguenth at gcc dot gnu.org @ 2015-02-19 13:49 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65120
--- Comment #4 from Richard Biener <rguenth at gcc dot gnu.org> ---
Oh, you can also workaround with
if (b == !!a)
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug c/65120] [5 Regression] Wlogical-not-parentheses should not warn about double exclamation !!
2015-02-19 13:39 [Bug c/65120] New: [gcc5] Wlogical-not-parentheses should not wanr about double exclamation !! jirislaby at gmail dot com
` (3 preceding siblings ...)
2015-02-19 13:49 ` rguenth at gcc dot gnu.org
@ 2015-02-19 14:48 ` jakub at gcc dot gnu.org
2015-02-19 21:46 ` jakub at gcc dot gnu.org
` (7 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: jakub at gcc dot gnu.org @ 2015-02-19 14:48 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65120
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |jakub at gcc dot gnu.org
--- Comment #5 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Looks reasonable, I'll take a look.
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug c/65120] [5 Regression] Wlogical-not-parentheses should not warn about double exclamation !!
2015-02-19 13:39 [Bug c/65120] New: [gcc5] Wlogical-not-parentheses should not wanr about double exclamation !! jirislaby at gmail dot com
` (4 preceding siblings ...)
2015-02-19 14:48 ` jakub at gcc dot gnu.org
@ 2015-02-19 21:46 ` jakub at gcc dot gnu.org
2015-02-27 6:30 ` aldyh at gcc dot gnu.org
` (6 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: jakub at gcc dot gnu.org @ 2015-02-19 21:46 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65120
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |ASSIGNED
Assignee|unassigned at gcc dot gnu.org |jakub at gcc dot gnu.org
--- Comment #6 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Created attachment 34811
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=34811&action=edit
gcc5-pr65120.patch
Untested fix.
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug c/65120] [5 Regression] Wlogical-not-parentheses should not warn about double exclamation !!
2015-02-19 13:39 [Bug c/65120] New: [gcc5] Wlogical-not-parentheses should not wanr about double exclamation !! jirislaby at gmail dot com
` (5 preceding siblings ...)
2015-02-19 21:46 ` jakub at gcc dot gnu.org
@ 2015-02-27 6:30 ` aldyh at gcc dot gnu.org
2015-02-27 8:25 ` mpolacek at gcc dot gnu.org
` (5 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: aldyh at gcc dot gnu.org @ 2015-02-27 6:30 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65120
Aldy Hernandez <aldyh at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |aldyh at gcc dot gnu.org
--- Comment #7 from Aldy Hernandez <aldyh at gcc dot gnu.org> ---
Causes c-c++-common/pr62199-2.c failures:
+FAIL: c-c++-common/pr62199-2.c -Wc++-compat (test for warnings, line 14)
+FAIL: c-c++-common/pr62199-2.c -Wc++-compat (test for warnings, line 15)
+FAIL: c-c++-common/pr62199-2.c -Wc++-compat (test for warnings, line 16)
+FAIL: c-c++-common/pr62199-2.c -Wc++-compat (test for warnings, line 17)
+FAIL: c-c++-common/pr62199-2.c -Wc++-compat (test for warnings, line 18)
+FAIL: c-c++-common/pr62199-2.c -Wc++-compat (test for warnings, line 19)
+FAIL: c-c++-common/pr62199-2.c -std=gnu++11 (test for warnings, line 14)
+FAIL: c-c++-common/pr62199-2.c -std=gnu++11 (test for warnings, line 15)
+FAIL: c-c++-common/pr62199-2.c -std=gnu++11 (test for warnings, line 16)
+FAIL: c-c++-common/pr62199-2.c -std=gnu++11 (test for warnings, line 17)
+FAIL: c-c++-common/pr62199-2.c -std=gnu++11 (test for warnings, line 18)
+FAIL: c-c++-common/pr62199-2.c -std=gnu++11 (test for warnings, line 19)
+FAIL: c-c++-common/pr62199-2.c -std=gnu++14 (test for warnings, line 14)
+FAIL: c-c++-common/pr62199-2.c -std=gnu++14 (test for warnings, line 15)
+FAIL: c-c++-common/pr62199-2.c -std=gnu++14 (test for warnings, line 16)
+FAIL: c-c++-common/pr62199-2.c -std=gnu++14 (test for warnings, line 17)
+FAIL: c-c++-common/pr62199-2.c -std=gnu++14 (test for warnings, line 18)
+FAIL: c-c++-common/pr62199-2.c -std=gnu++14 (test for warnings, line 19)
+FAIL: c-c++-common/pr62199-2.c -std=gnu++98 (test for warnings, line 14)
+FAIL: c-c++-common/pr62199-2.c -std=gnu++98 (test for warnings, line 15)
+FAIL: c-c++-common/pr62199-2.c -std=gnu++98 (test for warnings, line 16)
+FAIL: c-c++-common/pr62199-2.c -std=gnu++98 (test for warnings, line 17)
+FAIL: c-c++-common/pr62199-2.c -std=gnu++98 (test for warnings, line 18)
+FAIL: c-c++-common/pr62199-2.c -std=gnu++98 (test for warnings, line 19)
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug c/65120] [5 Regression] Wlogical-not-parentheses should not warn about double exclamation !!
2015-02-19 13:39 [Bug c/65120] New: [gcc5] Wlogical-not-parentheses should not wanr about double exclamation !! jirislaby at gmail dot com
` (6 preceding siblings ...)
2015-02-27 6:30 ` aldyh at gcc dot gnu.org
@ 2015-02-27 8:25 ` mpolacek at gcc dot gnu.org
2015-03-04 11:38 ` rguenth at gcc dot gnu.org
` (4 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2015-02-27 8:25 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65120
Marek Polacek <mpolacek at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |mpolacek at gcc dot gnu.org
--- Comment #8 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
The pr62199-2.c test is tweaked in the posted version of the patch:
https://gcc.gnu.org/ml/gcc-patches/2015-02/msg01237.html
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug c/65120] [5 Regression] Wlogical-not-parentheses should not warn about double exclamation !!
2015-02-19 13:39 [Bug c/65120] New: [gcc5] Wlogical-not-parentheses should not wanr about double exclamation !! jirislaby at gmail dot com
` (7 preceding siblings ...)
2015-02-27 8:25 ` mpolacek at gcc dot gnu.org
@ 2015-03-04 11:38 ` rguenth at gcc dot gnu.org
2015-03-06 9:47 ` rguenth at gcc dot gnu.org
` (3 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: rguenth at gcc dot gnu.org @ 2015-03-04 11:38 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65120
--- Comment #9 from Richard Biener <rguenth at gcc dot gnu.org> ---
Btw, just saw
> [ 2808s] ../drivers/xen/sfc_netfront/falcon_event.c:113:43: error: logical
> not is only applied to the left hand side of comparison
> [-Werror=logical-not-parentheses]
> [ 2808s] BUG_ON(!QWORD_GET_U(RX_EV_BYTE_CNT, *ev) == 0);
> [ 2808s] ^
which I think we should preserve - so make sure that the !! special-casing
doesn't cover this case from macro expansion.
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug c/65120] [5 Regression] Wlogical-not-parentheses should not warn about double exclamation !!
2015-02-19 13:39 [Bug c/65120] New: [gcc5] Wlogical-not-parentheses should not wanr about double exclamation !! jirislaby at gmail dot com
` (8 preceding siblings ...)
2015-03-04 11:38 ` rguenth at gcc dot gnu.org
@ 2015-03-06 9:47 ` rguenth at gcc dot gnu.org
2015-03-09 18:27 ` jakub at gcc dot gnu.org
` (2 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: rguenth at gcc dot gnu.org @ 2015-03-06 9:47 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65120
--- Comment #10 from Richard Biener <rguenth at gcc dot gnu.org> ---
It was just noted that
"But then again (!a == 0) is the same as !(a == 0), so the warning
is pretty pointless when the right side is constant zero."
so we should probably not warn for this case either.
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug c/65120] [5 Regression] Wlogical-not-parentheses should not warn about double exclamation !!
2015-02-19 13:39 [Bug c/65120] New: [gcc5] Wlogical-not-parentheses should not wanr about double exclamation !! jirislaby at gmail dot com
` (9 preceding siblings ...)
2015-03-06 9:47 ` rguenth at gcc dot gnu.org
@ 2015-03-09 18:27 ` jakub at gcc dot gnu.org
2015-03-10 6:39 ` jakub at gcc dot gnu.org
2015-03-10 6:43 ` jakub at gcc dot gnu.org
12 siblings, 0 replies; 14+ messages in thread
From: jakub at gcc dot gnu.org @ 2015-03-09 18:27 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65120
--- Comment #11 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Author: jakub
Date: Mon Mar 9 18:26:52 2015
New Revision: 221284
URL: https://gcc.gnu.org/viewcvs?rev=221284&root=gcc&view=rev
Log:
PR c/65120
* c-typeck.c (parser_build_binary_op): Don't warn for
!!x == y or !b == y where b is _Bool.
* parser.c (cp_parser_binary_expression): Don't warn for
!!x == y or !b == y where b is bool.
* c-c++-common/pr49706.c: Adjust tests for not warning
about !!x == y or !b == y where b is boolean, and add
some further tests.
* c-c++-common/pr62199-2.c: Likewise.
Modified:
trunk/gcc/c/ChangeLog
trunk/gcc/c/c-typeck.c
trunk/gcc/cp/ChangeLog
trunk/gcc/cp/parser.c
trunk/gcc/testsuite/ChangeLog
trunk/gcc/testsuite/c-c++-common/pr49706.c
trunk/gcc/testsuite/c-c++-common/pr62199-2.c
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug c/65120] [5 Regression] Wlogical-not-parentheses should not warn about double exclamation !!
2015-02-19 13:39 [Bug c/65120] New: [gcc5] Wlogical-not-parentheses should not wanr about double exclamation !! jirislaby at gmail dot com
` (10 preceding siblings ...)
2015-03-09 18:27 ` jakub at gcc dot gnu.org
@ 2015-03-10 6:39 ` jakub at gcc dot gnu.org
2015-03-10 6:43 ` jakub at gcc dot gnu.org
12 siblings, 0 replies; 14+ messages in thread
From: jakub at gcc dot gnu.org @ 2015-03-10 6:39 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65120
--- Comment #12 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Author: jakub
Date: Tue Mar 10 06:38:57 2015
New Revision: 221299
URL: https://gcc.gnu.org/viewcvs?rev=221299&root=gcc&view=rev
Log:
PR c/65120
* c-common.c (warn_logical_not_parentheses): Don't warn for
!x == 0 or !x != 0.
* c-typeck.c (parser_build_binary_op): Check for tcc_comparison
before preparing arguments to warn_logical_not_parentheses.
* parser.c (cp_parser_binary_expression): Check for tcc_comparison
before preparing arguments to warn_logical_not_parentheses.
Use maybe_constant_value on rhs.
* c-c++-common/pr49706.c (fn2): Don't expect warning if enumerator
on rhs is 0.
(fn4): New test.
* c-c++-common/pr65120.c: New test.
Added:
trunk/gcc/testsuite/c-c++-common/pr65120.c
Modified:
trunk/gcc/c-family/ChangeLog
trunk/gcc/c-family/c-common.c
trunk/gcc/c/ChangeLog
trunk/gcc/c/c-typeck.c
trunk/gcc/cp/ChangeLog
trunk/gcc/cp/parser.c
trunk/gcc/testsuite/ChangeLog
trunk/gcc/testsuite/c-c++-common/pr49706.c
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug c/65120] [5 Regression] Wlogical-not-parentheses should not warn about double exclamation !!
2015-02-19 13:39 [Bug c/65120] New: [gcc5] Wlogical-not-parentheses should not wanr about double exclamation !! jirislaby at gmail dot com
` (11 preceding siblings ...)
2015-03-10 6:39 ` jakub at gcc dot gnu.org
@ 2015-03-10 6:43 ` jakub at gcc dot gnu.org
12 siblings, 0 replies; 14+ messages in thread
From: jakub at gcc dot gnu.org @ 2015-03-10 6:43 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65120
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|ASSIGNED |RESOLVED
Resolution|--- |FIXED
--- Comment #13 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Fixed.
^ permalink raw reply [flat|nested] 14+ messages in thread
end of thread, other threads:[~2015-03-10 6:43 UTC | newest]
Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-02-19 13:39 [Bug c/65120] New: [gcc5] Wlogical-not-parentheses should not wanr about double exclamation !! jirislaby at gmail dot com
2015-02-19 13:41 ` [Bug c/65120] [5 Regression] Wlogical-not-parentheses should not warn " rguenth at gcc dot gnu.org
2015-02-19 13:41 ` [Bug c/65120] [gcc5] " jirislaby at gmail dot com
2015-02-19 13:42 ` [Bug c/65120] [5 Regression] " rguenth at gcc dot gnu.org
2015-02-19 13:49 ` rguenth at gcc dot gnu.org
2015-02-19 14:48 ` jakub at gcc dot gnu.org
2015-02-19 21:46 ` jakub at gcc dot gnu.org
2015-02-27 6:30 ` aldyh at gcc dot gnu.org
2015-02-27 8:25 ` mpolacek at gcc dot gnu.org
2015-03-04 11:38 ` rguenth at gcc dot gnu.org
2015-03-06 9:47 ` rguenth at gcc dot gnu.org
2015-03-09 18:27 ` jakub at gcc dot gnu.org
2015-03-10 6:39 ` jakub at gcc dot gnu.org
2015-03-10 6:43 ` jakub at gcc dot gnu.org
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).