public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/35547] -Wparentheses not useful in its current form
       [not found] <bug-35547-4@http.gcc.gnu.org/bugzilla/>
@ 2013-11-13 10:47 ` Ian.Kirkham at brownandsticky dot net
  0 siblings, 0 replies; 4+ messages in thread
From: Ian.Kirkham at brownandsticky dot net @ 2013-11-13 10:47 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35547

--- Comment #3 from Ian Kirkham <Ian.Kirkham at brownandsticky dot net> ---
-Wparentheses is potentially very useful but certainly too broad.

I agree that it would help if qualifiers could be added that split the coverage
to be able to distinguish between the extremes of 'very probably not intended'
from the 'might make intent more explicit'.
The former class should include:

    if (mask & 1 == 1) ...

the latter class should include:

    if (var1 == 1 && var2 == 2 || var1 = 2 && var2 == 1) ...

At the moment -Wparentheses will flag both as needing parens to scope the &/&&
operator. However, I argue that the latter is at worst a stylistic error
because adding the parens as suggested will not change the effect of the code.

However in the former case, adding the parens will certainly change the effect
of the code as there is a very strong likelihood that the bit-wise AND was
expected to have a higher precedence than the comparison operators.

Perhaps the suggested -Woperator-precedence qualifier should be two:

-Wsafe-operator-precedence
    flagging all the operator precedence categories

-Woperator-precedence
    flagging just those where bitwise operators are at the same lexical scope
as a comparison operator.


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug c/35547] -Wparentheses not useful in its current form
  2008-03-12  8:11 [Bug c/35547] New: " duz at sol-3 dot de
  2008-03-12 15:06 ` [Bug c/35547] " manu at gcc dot gnu dot org
  2008-03-12 18:39 ` joseph at codesourcery dot com
@ 2008-05-05  5:57 ` pinskia at gcc dot gnu dot org
  2 siblings, 0 replies; 4+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2008-05-05  5:57 UTC (permalink / raw)
  To: gcc-bugs



-- 

pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Severity|normal                      |enhancement


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35547


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug c/35547] -Wparentheses not useful in its current form
  2008-03-12  8:11 [Bug c/35547] New: " duz at sol-3 dot de
  2008-03-12 15:06 ` [Bug c/35547] " manu at gcc dot gnu dot org
@ 2008-03-12 18:39 ` joseph at codesourcery dot com
  2008-05-05  5:57 ` pinskia at gcc dot gnu dot org
  2 siblings, 0 replies; 4+ messages in thread
From: joseph at codesourcery dot com @ 2008-03-12 18:39 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from joseph at codesourcery dot com  2008-03-12 18:38 -------
Subject: Re:  -Wparentheses not useful in its current form

On Wed, 12 Mar 2008, manu at gcc dot gnu dot org wrote:

> My opinion is that since -Wparentheses appears in released versions, we should
> keep its behaviour as much as possible, even if the name could have been
> better. However, since many users are complaining about the precedence
> warnings, I agree it would be nice to move them out of -Wparentheses and into
> -Wprecedence, as proposed by Doug. I think this also should go into 4.3.1,
> since the new warnings were introduced in 4.3.0 and the change is quite safe.

The only thing documented in the release notes as new in 4.3.0 in this 
regard is that -Wparentheses works for C++ as it did for C.  I consider 
this a bug fix and don't think moving things out for one language only 
would be appropriate; instead, new options should be added in 4.4 and 
-Wparentheses and -Wall made to enable all the new options.

The question is not just whether the code writer knows the precedence 
issues, the option is also there to enforce a particular coding style to 
help code readers as well.  See the statistics on developer understanding 
of precedence that Derek Jones posted:

http://gcc.gnu.org/ml/gcc/2008-03/msg00486.html


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35547


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug c/35547] -Wparentheses not useful in its current form
  2008-03-12  8:11 [Bug c/35547] New: " duz at sol-3 dot de
@ 2008-03-12 15:06 ` manu at gcc dot gnu dot org
  2008-03-12 18:39 ` joseph at codesourcery dot com
  2008-05-05  5:57 ` pinskia at gcc dot gnu dot org
  2 siblings, 0 replies; 4+ messages in thread
From: manu at gcc dot gnu dot org @ 2008-03-12 15:06 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from manu at gcc dot gnu dot org  2008-03-12 15:05 -------
Bugzilla is not the appropriate place to seek opinions, gcc@gcc.gnu.org would
be a better place. This has been discussed already and there was some consensus
about splitting the warnings about precedence of operators out of
-Wparentheses.

http://gcc.gnu.org/ml/gcc/2007-12/msg00591.html
http://gcc.gnu.org/ml/gcc/2008-01/msg00134.html (continued).

My opinion is that since -Wparentheses appears in released versions, we should
keep its behaviour as much as possible, even if the name could have been
better. However, since many users are complaining about the precedence
warnings, I agree it would be nice to move them out of -Wparentheses and into
-Wprecedence, as proposed by Doug. I think this also should go into 4.3.1,
since the new warnings were introduced in 4.3.0 and the change is quite safe.


-- 

manu at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |manu at gcc dot gnu dot org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35547


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2013-11-13 10:47 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <bug-35547-4@http.gcc.gnu.org/bugzilla/>
2013-11-13 10:47 ` [Bug c/35547] -Wparentheses not useful in its current form Ian.Kirkham at brownandsticky dot net
2008-03-12  8:11 [Bug c/35547] New: " duz at sol-3 dot de
2008-03-12 15:06 ` [Bug c/35547] " manu at gcc dot gnu dot org
2008-03-12 18:39 ` joseph at codesourcery dot com
2008-05-05  5:57 ` 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).