<div class="gmail_quote">On Thu, Jun 9, 2011 at 10:41 AM, Frits van Bommel <span dir="ltr"><<a href="mailto:fvbommel@gmail.com">fvbommel@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div class="im">> Warn about cases such as<br>
><br>
> int foo(A a, bool b) {<br>
> return a + b ? 1 : 2; // user probably meant a + (b ? 1 : 2);<br>
> }<br>
><br>
> also when + is an overloaded operator call.<br>
<br>
</div>What happens when someone is silly enough to overloads an arithmetic<br>
operator to return bool?<br>
Sure it's not a good idea, but maybe you shouldn't produce *this*<br>
warning in that case...</blockquote></div><br><div>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.</div>
<div><br></div><div>The warning includes one fixit hint option which makes exactly that transformation.</div>