[quote name='Cornstalks' timestamp='1338475494' post='4944993']
[quote name='alvaro' timestamp='1338473232' post='4944982']
[quote name='L. Spiro' timestamp='1338459103' post='4944924']
It doesn’t mean you should go out of your way to write code that is safe under such a condition, it means never ever overload operators && or ||.
... or operator , (for the same reason).
[/quote]
Won't the comma operator always evaluate both the left side and the right side though (i.e. there shouldn't be any short circuiting, right?)? I don't think (guessing) it guarantees the order in which it evaluates its arguments when overloaded though, which certainly could be problematic (and is what I think you're pointing out).
[/quote]
I think he just meant it as a general comment that the comma operator changes behavior when overloaded, like && and ||, not whether the two sides are evaluated or not. The built in comma operator is a sequence point, but the overloaded operator is a function call and subject to the usual rules about order of evaluation.
[/quote]
Yes, that's what I think he meant. Maybe I just misunderstood what "for the same reason" implies, but it makes it sound like the reason is short-circuiting (or not short-circuiting), and I was just trying to clarify that the "same reason" here is that it will screw up programmers because the evaluation of the arguments is different than what most would expect, and not the short-circuiting reason.