On Nov 11, 2007, at 4:44 PM, Sanghyeon Seo wrote:

> Conditional operator expression may have side effect if one of its
> operands does.
>
> A patch with a test is attached.

This is a very nice patch, but I don't think it is appropriate.

?: itself doesn't have side effects.  The warning is reasonable in  
this code:

   i < j ? (sum += i) : (sum += j);

The issue is that the ?: expression itself returns a value, and that  
value is being ignored.  Why not use an if statement in this case?

-Chris
_______________________________________________
cfe-dev mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev

Reply via email to