On Sep 26, 2013, at 4:19 , Daniel Marjamäki <[email protected]> 
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
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits

Reply via email to