PATCH RFA: Fix -Wparentheses fallout

Gabriel Dos Reis gdr@integrable-solutions.net
Tue Jan 9 05:23:00 GMT 2007


Ian Lance Taylor <iant@google.com> writes:

| Daniel Jacobowitz <drow@false.org> writes:
| 
| > On Sun, Jan 07, 2007 at 09:16:37PM -0800, Ian Lance Taylor wrote:
| > > +bool
| > > +bar ()
| > > +{
| > > +  c = a = b;
| > > +  foo (0);
| > > +  return a = b;
| > > +}
| > 
| > Maybe it's just me, but I think that second one deserves a warning.
| > If it's possible to distinguish the two, anyway.
| 
| Hmmm.  I guess I don't think it deserves a warning.  Consider
| 
| int glob;
| int
| foo (int i)
| {
|   return glob = i;
| }
| 
| It seems to me that we shouldn't warn about that.  And it is
| isomorphic to the example with bool (in the code quoted above, all
| variables have type bool).
| 
| Any other opinions?

The above, e.g. return lhs = rhs, is an idiomatic construct in C++, to
the point that it deserved a departure from C.
But, I'm unclear about the audience of -Wparenthesis, so that may not
count. 

-- Gaby



More information about the Gcc-patches mailing list