[cfe-dev] C11, -Wunsequenced and aliasing

Sam Elliott via cfe-dev cfe-dev at lists.llvm.org
Thu Aug 17 12:35:20 PDT 2017


Hi Cfe-dev,

I asked the questions below on cfe-users, to no reply. I was wondering if any clang developers could shed light on this issue.

Sam

> On 26 Jul 2017, at 4:38 pm, Archibald Samuel Elliott <ashe2 at cs.washington.edu> wrote:
> 
> Hi Clang-users!
> 
> What are the expectations for the -Wunsequenced warning in Clang with C11?
> 
> My understanding was the following expression would be unsequenced according to the spec, but clang doesn't give me a warning:
> 
> ((*p = 3) + (*q = 4))
> 
> Is clang only going to warn if it knows p and q definitely alias each other here?
> 
> I also tried the expression:
> 
> ((*p = 3) + (*p = 4))
> 
> Which also gave no warnings, despite p aliasing itself. 
> 
> 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?
> 
> Maybe this kind of analysis isn't for clang, and instead is for the clang static analyser. 
> 
> Thank you in advance!
> 
> Sam

--
Archibald Sam Elliott
ashe2 at cs.washington.edu
PhD Student, PLSE Group

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20170817/63bf9098/attachment.html>


More information about the cfe-dev mailing list