public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/17946] wanted: warning for "a && MASK" when "a & MASK" was probably intended
[not found] <bug-17946-4397@http.gcc.gnu.org/bugzilla/>
@ 2006-01-24 20:33 ` trt at acm dot org
2007-02-19 10:21 ` mueller at gcc dot gnu dot org
` (6 subsequent siblings)
7 siblings, 0 replies; 18+ messages in thread
From: trt at acm dot org @ 2006-01-24 20:33 UTC (permalink / raw)
To: gcc-bugs
------- Comment #11 from trt at acm dot org 2006-01-24 20:33 -------
HP liked this warning suggestion. It will be in their next compiler release.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17946
^ permalink raw reply [flat|nested] 18+ messages in thread
* [Bug c/17946] wanted: warning for "a && MASK" when "a & MASK" was probably intended
[not found] <bug-17946-4397@http.gcc.gnu.org/bugzilla/>
2006-01-24 20:33 ` [Bug c/17946] wanted: warning for "a && MASK" when "a & MASK" was probably intended trt at acm dot org
@ 2007-02-19 10:21 ` mueller at gcc dot gnu dot org
2007-03-09 16:17 ` mueller at gcc dot gnu dot org
` (5 subsequent siblings)
7 siblings, 0 replies; 18+ messages in thread
From: mueller at gcc dot gnu dot org @ 2007-02-19 10:21 UTC (permalink / raw)
To: gcc-bugs
------- Comment #12 from mueller at gcc dot gnu dot org 2007-02-19 10:21 -------
I've submitted a patch
--
mueller at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
AssignedTo|unassigned at gcc dot gnu |mueller at gcc dot gnu dot
|dot org |org
Status|NEW |ASSIGNED
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17946
^ permalink raw reply [flat|nested] 18+ messages in thread
* [Bug c/17946] wanted: warning for "a && MASK" when "a & MASK" was probably intended
[not found] <bug-17946-4397@http.gcc.gnu.org/bugzilla/>
2006-01-24 20:33 ` [Bug c/17946] wanted: warning for "a && MASK" when "a & MASK" was probably intended trt at acm dot org
2007-02-19 10:21 ` mueller at gcc dot gnu dot org
@ 2007-03-09 16:17 ` mueller at gcc dot gnu dot org
2007-03-09 16:17 ` mueller at gcc dot gnu dot org
` (4 subsequent siblings)
7 siblings, 0 replies; 18+ messages in thread
From: mueller at gcc dot gnu dot org @ 2007-03-09 16:17 UTC (permalink / raw)
To: gcc-bugs
------- Comment #13 from mueller at gcc dot gnu dot org 2007-03-09 16:16 -------
Subject: Bug 17946
Author: mueller
Date: Fri Mar 9 16:16:35 2007
New Revision: 122751
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=122751
Log:
2007-03-09 Dirk Mueller <dmueller@suse.de>
PR c++/17946
* doc/invoke.texi (-Wlogical-op): Document.
* common.opt (-Wlogical-op): New.
* c-common.h (warn_logical_operator): Declare.
* c-common.c (warn_logical_operator): Define.
* c-typeck.c (parser_build_binary_op): Call
warn_logical_operator.
* cp/call.c (build_new_op): Call warn_logical_operator.
* testsuite/gcc.dg/Wlogical-op-1.c: New.
* testsuite/g++.dg/warn/Wlogical-op-1.C: New.
Added:
trunk/gcc/testsuite/g++.dg/warn/Wlogical-op-1.C
trunk/gcc/testsuite/gcc.dg/Wlogical-op-1.c
Modified:
trunk/gcc/ChangeLog
trunk/gcc/c-common.c
trunk/gcc/c-common.h
trunk/gcc/c-typeck.c
trunk/gcc/common.opt
trunk/gcc/cp/ChangeLog
trunk/gcc/cp/call.c
trunk/gcc/doc/invoke.texi
trunk/gcc/testsuite/ChangeLog
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17946
^ permalink raw reply [flat|nested] 18+ messages in thread
* [Bug c/17946] wanted: warning for "a && MASK" when "a & MASK" was probably intended
[not found] <bug-17946-4397@http.gcc.gnu.org/bugzilla/>
` (2 preceding siblings ...)
2007-03-09 16:17 ` mueller at gcc dot gnu dot org
@ 2007-03-09 16:17 ` mueller at gcc dot gnu dot org
2007-03-10 2:31 ` pinskia at gcc dot gnu dot org
` (3 subsequent siblings)
7 siblings, 0 replies; 18+ messages in thread
From: mueller at gcc dot gnu dot org @ 2007-03-09 16:17 UTC (permalink / raw)
To: gcc-bugs
------- Comment #14 from mueller at gcc dot gnu dot org 2007-03-09 16:17 -------
Fixed for 4.3.
--
mueller at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|ASSIGNED |RESOLVED
Resolution| |FIXED
Target Milestone|--- |4.3.0
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17946
^ permalink raw reply [flat|nested] 18+ messages in thread
* [Bug c/17946] wanted: warning for "a && MASK" when "a & MASK" was probably intended
[not found] <bug-17946-4397@http.gcc.gnu.org/bugzilla/>
` (3 preceding siblings ...)
2007-03-09 16:17 ` mueller at gcc dot gnu dot org
@ 2007-03-10 2:31 ` pinskia at gcc dot gnu dot org
2007-03-10 2:33 ` pinskia at gcc dot gnu dot org
` (2 subsequent siblings)
7 siblings, 0 replies; 18+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2007-03-10 2:31 UTC (permalink / raw)
To: gcc-bugs
------- Comment #15 from pinskia at gcc dot gnu dot org 2007-03-10 02:30 -------
on spu-elf, I get:
cc1plus: error: unrecognized command line option "-Winvariant-expr"^M
FAIL: g++.dg/warn/Wlogical-op-1.C (test for warnings, line 31) FAIL:
g++.dg/warn/Wlogical-op-1.C (test for warnings, line 33) PASS:
g++.dg/warn/Wlogical-op-1.C (test for bogus messages, line 36) PASS:
g++.dg/warn/Wlogical-op-1.C (test for bogus messages, line 39) PASS:
g++.dg/warn/Wlogical-op-1.C (test for bogus messages, line 40) PASS:
g++.dg/warn/Wlogical-op-1.C (test for bogus messages, line 42)
PASS: g++.dg/warn/Wlogical-op-1.C (test for bogus messages, line 44)
FAIL: g++.dg/warn/Wlogical-op-1.C (test for warnings, line 77) FAIL:
g++.dg/warn/Wlogical-op-1.C (test for warnings, line 79)
PASS: g++.dg/warn/Wlogical-op-1.C (test for bogus messages, line 82)
PASS: g++.dg/warn/Wlogical-op-1.C (test for bogus messages, line 85) PASS:
g++.dg/warn/Wlogical-op-1.C (test for bogus messages, line 86) PASS:
g++.dg/warn/Wlogical-op-1.C (test for bogus messages, line 88) PASS:
g++.dg/warn/Wlogical-op-1.C (test for bogus messages, line 90) FAIL:
g++.dg/warn/Wlogical-op-1.C (test for excess errors)
Did you forget to update the testcase before committing?
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17946
^ permalink raw reply [flat|nested] 18+ messages in thread
* [Bug c/17946] wanted: warning for "a && MASK" when "a & MASK" was probably intended
[not found] <bug-17946-4397@http.gcc.gnu.org/bugzilla/>
` (4 preceding siblings ...)
2007-03-10 2:31 ` pinskia at gcc dot gnu dot org
@ 2007-03-10 2:33 ` pinskia at gcc dot gnu dot org
2007-03-10 17:26 ` mueller at gcc dot gnu dot org
2007-03-10 21:43 ` manu at gcc dot gnu dot org
7 siblings, 0 replies; 18+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2007-03-10 2:33 UTC (permalink / raw)
To: gcc-bugs
------- Comment #16 from pinskia at gcc dot gnu dot org 2007-03-10 02:33 -------
(In reply to comment #15)
> on spu-elf, I get:
Likewise for the C testcase too.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17946
^ permalink raw reply [flat|nested] 18+ messages in thread
* [Bug c/17946] wanted: warning for "a && MASK" when "a & MASK" was probably intended
[not found] <bug-17946-4397@http.gcc.gnu.org/bugzilla/>
` (5 preceding siblings ...)
2007-03-10 2:33 ` pinskia at gcc dot gnu dot org
@ 2007-03-10 17:26 ` mueller at gcc dot gnu dot org
2007-03-10 21:43 ` manu at gcc dot gnu dot org
7 siblings, 0 replies; 18+ messages in thread
From: mueller at gcc dot gnu dot org @ 2007-03-10 17:26 UTC (permalink / raw)
To: gcc-bugs
------- Comment #17 from mueller at gcc dot gnu dot org 2007-03-10 17:26 -------
Subject: Bug 17946
Author: mueller
Date: Sat Mar 10 17:26:33 2007
New Revision: 122798
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=122798
Log:
2007-03-10 Dirk Mueller <dmueller@suse.de>
PR c++/17946
* gcc.dg/Wlogical-op-1.c: Remove duplicated part.
* g++.dg/warn/Wlogical-op-1.C: Remove duplicated part.
Modified:
trunk/gcc/testsuite/ChangeLog
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17946
^ permalink raw reply [flat|nested] 18+ messages in thread
* [Bug c/17946] wanted: warning for "a && MASK" when "a & MASK" was probably intended
[not found] <bug-17946-4397@http.gcc.gnu.org/bugzilla/>
` (6 preceding siblings ...)
2007-03-10 17:26 ` mueller at gcc dot gnu dot org
@ 2007-03-10 21:43 ` manu at gcc dot gnu dot org
7 siblings, 0 replies; 18+ messages in thread
From: manu at gcc dot gnu dot org @ 2007-03-10 21:43 UTC (permalink / raw)
To: gcc-bugs
------- Comment #18 from manu at gcc dot gnu dot org 2007-03-10 21:43 -------
(In reply to comment #17)
> Modified:
> trunk/gcc/testsuite/ChangeLog
>
Just Changelog changes??
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17946
^ permalink raw reply [flat|nested] 18+ messages in thread
* [Bug c/17946] wanted: warning for "a && MASK" when "a & MASK" was probably intended
2004-10-12 14:15 [Bug c/17946] New: " trt at acm dot org
` (8 preceding siblings ...)
2004-10-15 0:37 ` giovannibajo at libero dot it
@ 2004-12-08 18:48 ` trt at acm dot org
9 siblings, 0 replies; 18+ messages in thread
From: trt at acm dot org @ 2004-12-08 18:48 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From trt at acm dot org 2004-12-08 18:48 -------
I should mention there is a hack for the problem noted in comment #5: do the
temporary truthvalue conversions with warnings suppressed.
That is, change the two instances of
tree t = lang_hooks.truthvalue_conversion (default_conversion ($1.value));
to instead be
tree t;
inhibit_warnings++;
t = lang_hooks.truthvalue_conversion (default_conversion ($1.value));
inhibit_warnings--;
So, this can be "readily made to work" after all. But ugh.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17946
^ permalink raw reply [flat|nested] 18+ messages in thread
* [Bug c/17946] wanted: warning for "a && MASK" when "a & MASK" was probably intended
2004-10-12 14:15 [Bug c/17946] New: " trt at acm dot org
` (7 preceding siblings ...)
2004-10-14 17:33 ` bangerth at dealii dot org
@ 2004-10-15 0:37 ` giovannibajo at libero dot it
2004-12-08 18:48 ` trt at acm dot org
9 siblings, 0 replies; 18+ messages in thread
From: giovannibajo at libero dot it @ 2004-10-15 0:37 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From giovannibajo at libero dot it 2004-10-15 00:37 -------
I will confirm this because I agree with the submitter, this looks like a good
warning to use. It would be great if the conflict with the other warning can be
solved.
--
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Ever Confirmed| |1
Last reconfirmed|0000-00-00 00:00:00 |2004-10-15 00:37:05
date| |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17946
^ permalink raw reply [flat|nested] 18+ messages in thread
* [Bug c/17946] wanted: warning for "a && MASK" when "a & MASK" was probably intended
2004-10-12 14:15 [Bug c/17946] New: " trt at acm dot org
` (6 preceding siblings ...)
2004-10-14 15:54 ` trt at acm dot org
@ 2004-10-14 17:33 ` bangerth at dealii dot org
2004-10-15 0:37 ` giovannibajo at libero dot it
2004-12-08 18:48 ` trt at acm dot org
9 siblings, 0 replies; 18+ messages in thread
From: bangerth at dealii dot org @ 2004-10-14 17:33 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From bangerth at dealii dot org 2004-10-14 17:33 -------
Andrew, I'm getting angry when you selfishly close PRs that other people
think are useful to be kept open. The submitter of this PR has shown that
the cases you claim exist are not frequent, and that they often enough
point to real bugs. What more proof do you want that you argument is
wrong? This is, after all, an enhancement request, not a bug report. If
your code wrongly triggers this warning, just switch it off.
I would also like to remind you that we work based on consensus. If you
disagree with decisions by others, then that's fine, but you may not put
your opinions over those of others. If you close a PR and I reopen it,
don't close it again or we will have to discuss this on the bugmaster
mailing list. I consider your behavior disrespectful and rude.
Thanks
Wolfgang
--
What |Removed |Added
----------------------------------------------------------------------------
Status|RESOLVED |UNCONFIRMED
Resolution|INVALID |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17946
^ permalink raw reply [flat|nested] 18+ messages in thread
* [Bug c/17946] wanted: warning for "a && MASK" when "a & MASK" was probably intended
2004-10-12 14:15 [Bug c/17946] New: " trt at acm dot org
` (5 preceding siblings ...)
2004-10-14 14:31 ` pinskia at gcc dot gnu dot org
@ 2004-10-14 15:54 ` trt at acm dot org
2004-10-14 17:33 ` bangerth at dealii dot org
` (2 subsequent siblings)
9 siblings, 0 replies; 18+ messages in thread
From: trt at acm dot org @ 2004-10-14 15:54 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From trt at acm dot org 2004-10-14 15:54 -------
> a && 4 in their code meaning a != 0 && 4 !=0
That happens, but when it does `a' is not integer type. I use a gcc with this
warning on a 35Mloc code base. There are currently 4 warnings, all pointing to
real bugs.
This is an excellent warning, it just doesn't fit neatly into the gcc front end.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17946
^ permalink raw reply [flat|nested] 18+ messages in thread
* [Bug c/17946] wanted: warning for "a && MASK" when "a & MASK" was probably intended
2004-10-12 14:15 [Bug c/17946] New: " trt at acm dot org
` (4 preceding siblings ...)
2004-10-12 18:52 ` trt at acm dot org
@ 2004-10-14 14:31 ` pinskia at gcc dot gnu dot org
2004-10-14 15:54 ` trt at acm dot org
` (3 subsequent siblings)
9 siblings, 0 replies; 18+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-10-14 14:31 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From pinskia at gcc dot gnu dot org 2004-10-14 14:31 -------
I still say that people do have a && 4 in their code meaning a != 0 && 4 !=0. Also a & 1 should be
caught too but that would just give too many false postives so there is no way for GCC to warn about
this.
--
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution| |INVALID
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17946
^ permalink raw reply [flat|nested] 18+ messages in thread
* [Bug c/17946] wanted: warning for "a && MASK" when "a & MASK" was probably intended
2004-10-12 14:15 [Bug c/17946] New: " trt at acm dot org
` (3 preceding siblings ...)
2004-10-12 16:08 ` bangerth at dealii dot org
@ 2004-10-12 18:52 ` trt at acm dot org
2004-10-14 14:31 ` pinskia at gcc dot gnu dot org
` (4 subsequent siblings)
9 siblings, 0 replies; 18+ messages in thread
From: trt at acm dot org @ 2004-10-12 18:52 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From trt at acm dot org 2004-10-12 18:52 -------
Given the problem pointed out in
http://gcc.gnu.org/ml/gcc-patches/2004-10/msg01013.html I do not see how this
patch can be readily made to work. To avoid redundant truthvalue conversion it
might be necessary e.g. to change "enum tree_code original_code" to "tree
original_value" in c-tree.h with related changes to c-parse.in and c-typeck.c.
That might be justifiable for other reasons, but probably not this one.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17946
^ permalink raw reply [flat|nested] 18+ messages in thread
* [Bug c/17946] wanted: warning for "a && MASK" when "a & MASK" was probably intended
2004-10-12 14:15 [Bug c/17946] New: " trt at acm dot org
` (2 preceding siblings ...)
2004-10-12 14:45 ` trt at acm dot org
@ 2004-10-12 16:08 ` bangerth at dealii dot org
2004-10-12 18:52 ` trt at acm dot org
` (5 subsequent siblings)
9 siblings, 0 replies; 18+ messages in thread
From: bangerth at dealii dot org @ 2004-10-12 16:08 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From bangerth at dealii dot org 2004-10-12 16:07 -------
If this is put under a flag of its own, it may actually be useful. I
see no reason why we should dismiss it that quickly.
W.
--
What |Removed |Added
----------------------------------------------------------------------------
Status|RESOLVED |UNCONFIRMED
Resolution|INVALID |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17946
^ permalink raw reply [flat|nested] 18+ messages in thread
* [Bug c/17946] wanted: warning for "a && MASK" when "a & MASK" was probably intended
2004-10-12 14:15 [Bug c/17946] New: " trt at acm dot org
2004-10-12 14:19 ` [Bug c/17946] " pinskia at gcc dot gnu dot org
2004-10-12 14:27 ` pinskia at gcc dot gnu dot org
@ 2004-10-12 14:45 ` trt at acm dot org
2004-10-12 16:08 ` bangerth at dealii dot org
` (6 subsequent siblings)
9 siblings, 0 replies; 18+ messages in thread
From: trt at acm dot org @ 2004-10-12 14:45 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From trt at acm dot org 2004-10-12 14:45 -------
Patch here: http://gcc.gnu.org/ml/gcc-patches/2004-10/msg00990.html
This patch does not warn about "a && 1" for the reason noted in comment #1.
Some mistakes will go unwarned, but it still catches quite a lot.
The concern expressed in comment #2 is quite plausible, but I have not found it
to be an issue in practice. e.g. A gcc "make bootstrap" never triggers this
warning.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17946
^ permalink raw reply [flat|nested] 18+ messages in thread
* [Bug c/17946] wanted: warning for "a && MASK" when "a & MASK" was probably intended
2004-10-12 14:15 [Bug c/17946] New: " trt at acm dot org
2004-10-12 14:19 ` [Bug c/17946] " pinskia at gcc dot gnu dot org
@ 2004-10-12 14:27 ` pinskia at gcc dot gnu dot org
2004-10-12 14:45 ` trt at acm dot org
` (7 subsequent siblings)
9 siblings, 0 replies; 18+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-10-12 14:27 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From pinskia at gcc dot gnu dot org 2004-10-12 14:27 -------
Really we should not warn because we could be doing a && CONST where we want CONST to be
compared against 0 so this is invalid.
--
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution| |INVALID
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17946
^ permalink raw reply [flat|nested] 18+ messages in thread
* [Bug c/17946] wanted: warning for "a && MASK" when "a & MASK" was probably intended
2004-10-12 14:15 [Bug c/17946] New: " trt at acm dot org
@ 2004-10-12 14:19 ` pinskia at gcc dot gnu dot org
2004-10-12 14:27 ` pinskia at gcc dot gnu dot org
` (8 subsequent siblings)
9 siblings, 0 replies; 18+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-10-12 14:19 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From pinskia at gcc dot gnu dot org 2004-10-12 14:19 -------
I the only way this can be done right is not to warn about a && 1 as people sometimes do that
(especially with macros) and that shows up in GCC a huge amount.
--
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |diagnostic
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17946
^ permalink raw reply [flat|nested] 18+ messages in thread
end of thread, other threads:[~2007-03-10 21:43 UTC | newest]
Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <bug-17946-4397@http.gcc.gnu.org/bugzilla/>
2006-01-24 20:33 ` [Bug c/17946] wanted: warning for "a && MASK" when "a & MASK" was probably intended trt at acm dot org
2007-02-19 10:21 ` mueller at gcc dot gnu dot org
2007-03-09 16:17 ` mueller at gcc dot gnu dot org
2007-03-09 16:17 ` mueller at gcc dot gnu dot org
2007-03-10 2:31 ` pinskia at gcc dot gnu dot org
2007-03-10 2:33 ` pinskia at gcc dot gnu dot org
2007-03-10 17:26 ` mueller at gcc dot gnu dot org
2007-03-10 21:43 ` manu at gcc dot gnu dot org
2004-10-12 14:15 [Bug c/17946] New: " trt at acm dot org
2004-10-12 14:19 ` [Bug c/17946] " pinskia at gcc dot gnu dot org
2004-10-12 14:27 ` pinskia at gcc dot gnu dot org
2004-10-12 14:45 ` trt at acm dot org
2004-10-12 16:08 ` bangerth at dealii dot org
2004-10-12 18:52 ` trt at acm dot org
2004-10-14 14:31 ` pinskia at gcc dot gnu dot org
2004-10-14 15:54 ` trt at acm dot org
2004-10-14 17:33 ` bangerth at dealii dot org
2004-10-15 0:37 ` giovannibajo at libero dot it
2004-12-08 18:48 ` trt at acm dot 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).