<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On 17 August 2017 at 12:35, Sam Elliott via cfe-dev <span dir="ltr"><<a href="mailto:cfe-dev@lists.llvm.org" target="_blank">cfe-dev@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word">Hi Cfe-dev,<div><br></div><div>I asked the questions below on cfe-users, to no reply. I was wondering if any clang developers could shed light on this issue.</div><div><br></div><div>Sam</div><div><br><div><blockquote type="cite"><div>On 26 Jul 2017, at 4:38 pm, Archibald Samuel Elliott <<a href="mailto:ashe2@cs.washington.edu" target="_blank">ashe2@cs.washington.edu</a>> wrote:</div><br class="m_5690009908344252804Apple-interchange-newline"><div><div>Hi Clang-users!<br><br>What are the expectations for the -Wunsequenced warning in Clang with C11?<br><br>My understanding was the following expression would be unsequenced according to the spec, but clang doesn't give me a warning:<br><br>((*p = 3) + (*q = 4))<br><br>Is clang only going to warn if it knows p and q definitely alias each other here?<br><br>I also tried the expression:<br><br>((*p = 3) + (*p = 4))<br><br>Which also gave no warnings, despite p aliasing itself. <br><br>Is the warning based on a heuristic of whether the unsequenced behaviour will be observable, or on whether the two assignments ever alias, or will it only warn if it knows two side-effecting expressions are definitely unsequenced?<br></div></div></blockquote></div></div></div></blockquote><div>Clang's warning is extremely superficial and conservative at the moment: it only warns if it sees unsequenced operations on the same variable, which is referenced directly. So ((n = 3) + (n = 4)) will warn, but ((*p = 3) + (*p = 4)) will not.<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><div><div><blockquote type="cite"><div><div>Maybe this kind of analysis isn't for clang, and instead is for the clang static analyser. </div></div></blockquote></div></div></div></blockquote><div>Yes, if you want to be able to catch more subtle cases, and especially cases where two different pointers may alias the same storage, that would be best handled by the Clang Static Analyzer (though I think it doesn't have any checking for unsequenced operations as yet).</div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><div><div><blockquote type="cite"><div><div>Thank you in advance!<br><br>Sam</div></div></blockquote></div><br><div>
<div style="color:rgb(0,0,0);letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;word-wrap:break-word"><div style="color:rgb(0,0,0);letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;word-wrap:break-word"><div style="color:rgb(0,0,0);letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;word-wrap:break-word"><div style="color:rgb(0,0,0);letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;word-wrap:break-word"><div style="color:rgb(0,0,0);letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;word-wrap:break-word"><div>--</div><div>Archibald Sam Elliott</div><div><a href="mailto:ashe2@cs.washington.edu" target="_blank">ashe2@cs.washington.edu</a></div><div>PhD Student, PLSE Group</div></div></div></div></div></div>
</div>
<br></div></div><br>______________________________<wbr>_________________<br>
cfe-dev mailing list<br>
<a href="mailto:cfe-dev@lists.llvm.org">cfe-dev@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/cfe-dev</a><br>
<br></blockquote></div><br></div></div>