<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Mar 23, 2015 at 5:03 PM, Kaylor, Andrew <span dir="ltr"><<a href="mailto:andrew.kaylor@intel.com" target="_blank">andrew.kaylor@intel.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">





<div lang="EN-US" link="blue" vlink="purple">
<div><span class="">
<p class="MsoNormal">>> warning C4706: assignment within conditional expression (296 times)<u></u><u></u></p>
<p class="MsoNormal">> Only 300? I was going to say that I assume this warning doesn't support the double-paren suppression that GCC/Clang's -Wparentheses dictate, but with such a low hit rate I wonder if it's some other sub-set of cases MSVC is seeing here.
 (or maybe we don't use even parentheses-bound assignment in conditionals very often at all)<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
</span><p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">Yeah, I expected more too.  I haven’t looked at any of these to see what might explain it.<u></u><u></u></span></p><span class="">
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">>> warning C4389: signed/unsigned mismatch (28 times)<u></u><u></u></p>
<p class="MsoNormal">> Wonder how this is different from C4245?<u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"><u></u> <u></u></span></p>
</span><p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">C4245 seems to apply specifically to const values that the compiler knows to have a negative value.<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">See examples: <a href="https://msdn.microsoft.com/en-us/library/e9s7thk1.aspx" target="_blank">https://msdn.microsoft.com/en-us/library/e9s7thk1.aspx</a><u></u><u></u></span></p><span class="">
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="color:black">>> warning C4189: local variable is initialized but not referenced (6 times)<u></u><u></u></span></p>
<p class="MsoNormal"><span style="color:black">> Clang diagnoses cases like this already - I wonder what subset MSVC is catching that Clang is not. If it's types with non-trivial construction/destruction, then this seems like a warning we might not want to
 enable - it might false-positive on scoped devices, etc.</span><span style="color:#1f497d"><u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"><u></u> <u></u></span></p>
</span><p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">Some of these were cases where the code was getting an object pointer and then using it to call a static function.  The other cause was places where a template
 parameter in a compound condition had the potential to short circuit evaluation of the condition and thus skip the only use of the local variable.<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">In the former case, fixing the code to avoid the warning seems like an improvement.</span></p></div></div></blockquote><div><br>Yeah, sounds fine - but also doesn't sound like it's worth holding as a bar for LLVM, so I'd still be sort of inclined to disable the warning rather than produce noise for MSVC-using developers that the rest of the community isn't really going to worry about (we'd never implement such a warning in Clang, for example - I doubt it'd even be worth a clang-tidy warning, but it'd be on the edge)<br> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div lang="EN-US" link="blue" vlink="purple"><div><p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"><u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"><u></u> </span><span style="color:rgb(31,73,125);font-family:Calibri,sans-serif;font-size:11pt">I don’t know if MSVC only warns in the second case if the template is actually instantiated with a value that short circuits the condition.  If not, that one
 definitely seems like a nuisance but it was easy enough to fix in the places where it was being reported.</span></p></div></div></blockquote><div><br>*nod*<br> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div lang="EN-US" link="blue" vlink="purple"><div><span class="">
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="color:black">>> warning C4611: interaction between '_setjmp' and C++ object destruction is non-portable (2 times)<u></u><u></u></span></p>
<p class="MsoNormal"><span style="color:black">> Curious - again, worth comparing whatever false positives to whatever holes clang might have, etc.<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"><u></u> <u></u></span></p>
</span><p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">This one looks potentially serious to me, but it isn’t obvious what to do about it so I ended up adding this to the list of warnings I’m going to just disable. 
 It’s a design issue.<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">Both instances of the warning occurred in the same place, CrashRecoveryContext::runSafely().<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">It may be that the best thing to do here is to just document the potentially platform-dependent behavior if it really isn’t consistent across the platforms
 we support.</span></p></div></div></blockquote><div><br>I wonder if the warning is only about the non-trivial function_ref object, or whether it'd fire there regardless? It'd be interesting to know the limitations/point of the warning in more detail. But yeah, given the small number of cases it comes up in & it's not likely to get any worse - we're hardly going to litter the codebase with setjmp/longjmp - so if the current use case is safe (I've no idea), probably just disable the warning & move on.<br><br>- David<br> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div lang="EN-US" link="blue" vlink="purple"><div><p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"><u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">-Andy<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"><u></u> <u></u></span></p>
</div>
</div>

</blockquote></div><br></div></div>