Ew. That seems like the type of problem which shouldn't have to be debugged, because the code shouldn't have been written like that to begin with.
Heck, it seems like the compiler shouldn't even allow that code to compile in the first place... But I guess there are technical problems with disallowing that? (Not the least of which is, it would break existing code.)
The issue comes from some vagueness in the wording from the C standard. The expression is valid from a literal interpretation of the rules, but to eliminate it would require a much more convoluted set of rules. Remember that C historically was a single-pass compiler ...
And if you want to get even funkier, try this in other languages (python yields 2, bash yields 4)
For those that didn't understand, my point with the python example was to emphasize that the same expression (visually) can have different meanings in different languages, and that the parse rules can be different. I am aware that python doesn't parse it in the way that the expression appears to a C programmer :)
Concerning python's lack of pre and post increment, the decision was made primarily because there are a lot of confusing situations, such as the aforementioned, with the increment and decrement operators. However, the decision to allow x++x to be valid, and parsed as x + (+ x) = x + x, is itself terribly confusing and germane to the original discussion
You appear to not understand how Python works. Python has no increment operators; your statement is equivalent to "x + ++++x" or "x + x", using the unary + operator.