<div dir="ltr"><div dir="ltr"><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, May 18, 2020 at 10:49 AM Roman Lebedev <<a href="mailto:lebedev.ri@gmail.com">lebedev.ri@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">On Mon, May 18, 2020 at 8:44 PM Billy Araujo via cfe-dev<br>
<<a href="mailto:cfe-dev@lists.llvm.org" target="_blank">cfe-dev@lists.llvm.org</a>> wrote:<br>
><br>
> Hi David,<br>
><br>
> So I guess this is expected behaviour. Thanks.<br>
><br>
> Regards,<br>
><br>
> Billy.<br>
><br>
><br>
> On Mon, May 18, 2020 at 6:39 PM David Blaikie <<a href="mailto:dblaikie@gmail.com" target="_blank">dblaikie@gmail.com</a>> wrote:<br>
>><br>
>> GCC doesn't seem to warn on this either. On the basis of the original warning I could see how this case could merit similar handling - but I doubt we'd want to add that handling to the existing flag at this point (due to the number of people over the decades that have used the warning for the behavior it currently provides, not expecting the new/additional behavior for the ternary operator or other bool-testing assignment situations (eg: "void f(bool); f(x = 5);")<br>
>><br>
>> On Mon, May 18, 2020 at 6:53 AM Billy Araujo via cfe-dev <<a href="mailto:cfe-dev@lists.llvm.org" target="_blank">cfe-dev@lists.llvm.org</a>> wrote:<br>
>>><br>
>>> -Wparentheses<br>
>>><br>
>>> warns for line 3 but not for the ternary expression in line 2.<br>
>>><br>
>>> 1 static void foo(int a, int b, int x) {<br>
>>> 2 x = (x = 10) ? a : b;<br>
>>> 3 if (x = 10) { x = a; } else { x = b; }<br>
>>> 4 }<br>
>>><br>
>>> Is this a bug?<br>
This seems pretty correct to me.<br>
<br>
You can't avoid braces on line 3, so those braces don't count as extra braces<br>
to silence the diagnostic, while the situation on the line 2 is opposite,<br>
no braces are needed there, so the braces count as silencers.<br></blockquote><div><br></div><div>But braces are needed there, I think, otherwise precedence makes "i = 3 ? a : b" into "i = (3 ? a : b)", right?</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
I.e. if line 2 *would* be diagnosed, i'd say that is a false-positive.<br>
<br>
>>> Regards,<br>
>>><br>
>>> Billy.<br>
Roman<br>
<br>
>>> _______________________________________________<br>
>>> cfe-dev mailing list<br>
>>> <a href="mailto:cfe-dev@lists.llvm.org" target="_blank">cfe-dev@lists.llvm.org</a><br>
>>> <a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev" rel="noreferrer" target="_blank">https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev</a><br>
><br>
> _______________________________________________<br>
> cfe-dev mailing list<br>
> <a href="mailto:cfe-dev@lists.llvm.org" target="_blank">cfe-dev@lists.llvm.org</a><br>
> <a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev" rel="noreferrer" target="_blank">https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev</a><br>
</blockquote></div></div>