[PATCH][StaticAnalyzer] new check comparing equal expression
    Jordan Rose 
    jordan_rose at apple.com
       
    Thu Sep 26 17:16:30 PDT 2013
    
    
  
On Sep 26, 2013, at 4:19 , Daniel Marjamäki <Daniel.Marjamaki at evidente.se> wrote:
> Hi Jordan!
> 
>> Even though this actually does something ("++x == ++x"), it's not well-defined anyway (specifically, either one could go first), so I'd still like to catch this as a copy-paste error. What do you think?
> 
> Yes this is true now as we are only checking comparison operators. However:
> 
> 1. When we extend it to && and || operators we must be more careful about this. We can of course add logic later that avoids increment only if the top operator is && or ||.
> 
> 2. I think it would be interesting to add new diagnostics about undefined execution order. Then we will warn about ("++x == ++x") with a stronger warning message that complains about undefined behaviour. 
We actually do have that already:
<stdin>:3:2: warning: multiple unsequenced modifications to 'x' [-Wunsequenced]
        ++x == ++x;
        ^      ~~
So maybe it's okay.
Jordan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20130926/88fddfae/attachment.html>
    
    
More information about the cfe-commits
mailing list