On Thu, Jun 9, 2011 at 10:41 AM, Frits van Bommel <[email protected]>wrote:
> > Warn about cases such as
> >
> > int foo(A a, bool b) {
> > return a + b ? 1 : 2; // user probably meant a + (b ? 1 : 2);
> > }
> >
> > also when + is an overloaded operator call.
>
> What happens when someone is silly enough to overloads an arithmetic
> operator to return bool?
> Sure it's not a good idea, but maybe you shouldn't produce *this*
> warning in that case...
If you're imagining the "+" above is an operator returning a bool, I *still*
think we should warn here, and require ()s around the condition expression
to silence the warning. Other readers of the code will likely be surprised
at this being the intended behavior.
The warning includes one fixit hint option which makes exactly that
transformation.
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits