public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/17896] New: The expression (a>0 & b>0) should give clearer warning message (-Wparentheses)
@ 2004-10-08 19:55 trt at acm dot org
2004-10-08 20:00 ` [Bug c/17896] " trt at acm dot org
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: trt at acm dot org @ 2004-10-08 19:55 UTC (permalink / raw)
To: gcc-bugs
gcc -Wparentheses, for the expression:
a & b == c
warns "suggest parentheses around comparison in operand of &".
This is good, but alas the same warning is issued for:
a>0 & b>0
Here it does not matter whether & or && are used, the semantics are identical.
(In my experience, 75% of such instances are "harmless" in this way.)
This deserves a clearer warning such as:
suggest && instead of & when joining booleans
There is a similar issue with || versus |
And also != versus ^ but that is fairly obscure so I will ignore it.
--
Summary: The expression (a>0 & b>0) should give clearer warning
message (-Wparentheses)
Product: gcc
Version: 4.0.0
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: c
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: trt at acm dot org
CC: gcc-bugs at gcc dot gnu dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17896
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c/17896] The expression (a>0 & b>0) should give clearer warning message (-Wparentheses)
2004-10-08 19:55 [Bug c/17896] New: The expression (a>0 & b>0) should give clearer warning message (-Wparentheses) trt at acm dot org
@ 2004-10-08 20:00 ` trt at acm dot org
2004-10-08 20:11 ` pinskia at gcc dot gnu dot org
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: trt at acm dot org @ 2004-10-08 20:00 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From trt at acm dot org 2004-10-08 20:00 -------
Created an attachment (id=7310)
--> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=7310&action=view)
proposed patch
I've attached a proposed patch for gcc to issue alternate warnings:
suggest && instead of & when joining booleans
suggest || instead of | when joining booleans
The patched gcc continues to warn (or not) as before, but with different text
when the operands are boolean-valued and without side effects.
I used COMPARISON_CLASS_P (t) as an approximation to "boolean-valued".
truth_value_p (TREE_CODE (t)) would be better but is unavailable.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17896
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c/17896] The expression (a>0 & b>0) should give clearer warning message (-Wparentheses)
2004-10-08 19:55 [Bug c/17896] New: The expression (a>0 & b>0) should give clearer warning message (-Wparentheses) trt at acm dot org
2004-10-08 20:00 ` [Bug c/17896] " trt at acm dot org
@ 2004-10-08 20:11 ` pinskia at gcc dot gnu dot org
2004-10-09 21:24 ` trt at acm dot org
2004-10-11 17:12 ` pinskia at gcc dot gnu dot org
3 siblings, 0 replies; 5+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-10-08 20:11 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From pinskia at gcc dot gnu dot org 2004-10-08 20:11 -------
As I have mentioned before patches goto gcc-patches@gcc.gnu.org.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17896
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c/17896] The expression (a>0 & b>0) should give clearer warning message (-Wparentheses)
2004-10-08 19:55 [Bug c/17896] New: The expression (a>0 & b>0) should give clearer warning message (-Wparentheses) trt at acm dot org
2004-10-08 20:00 ` [Bug c/17896] " trt at acm dot org
2004-10-08 20:11 ` pinskia at gcc dot gnu dot org
@ 2004-10-09 21:24 ` trt at acm dot org
2004-10-11 17:12 ` pinskia at gcc dot gnu dot org
3 siblings, 0 replies; 5+ messages in thread
From: trt at acm dot org @ 2004-10-09 21:24 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From trt at acm dot org 2004-10-09 21:24 -------
Sorry, will do. Should bugzilla do this automatically for 'patch' attachments?
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17896
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c/17896] The expression (a>0 & b>0) should give clearer warning message (-Wparentheses)
2004-10-08 19:55 [Bug c/17896] New: The expression (a>0 & b>0) should give clearer warning message (-Wparentheses) trt at acm dot org
` (2 preceding siblings ...)
2004-10-09 21:24 ` trt at acm dot org
@ 2004-10-11 17:12 ` pinskia at gcc dot gnu dot org
3 siblings, 0 replies; 5+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-10-11 17:12 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From pinskia at gcc dot gnu dot org 2004-10-11 17:12 -------
Patch here: <http://gcc.gnu.org/ml/gcc-patches/2004-10/msg00918.html>.
Confirmed.
--
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Ever Confirmed| |1
Keywords| |diagnostic, patch
Last reconfirmed|0000-00-00 00:00:00 |2004-10-11 17:12:24
date| |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17896
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2004-10-11 17:12 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-10-08 19:55 [Bug c/17896] New: The expression (a>0 & b>0) should give clearer warning message (-Wparentheses) trt at acm dot org
2004-10-08 20:00 ` [Bug c/17896] " trt at acm dot org
2004-10-08 20:11 ` pinskia at gcc dot gnu dot org
2004-10-09 21:24 ` trt at acm dot org
2004-10-11 17:12 ` pinskia at gcc dot gnu 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).