You seem to be hung up on the difference between syntax and semantics.
"Colourless green ideas sleep furiously".
Perfect syntax, but utterly meaningless.
Nobody is arguing that a ^= b ^= a ^= b; is invalid syntax. For sure any half decent compiler will have no trouble parsing it, and outputting some sequence of instructions which do "something".
But that isn't the problem, it's a semantic issue - the code doesn't mean anything - it's undefined.
Now your limited experience - as judged by your comment in ignorance "This "SCO Optimizing C compiler (icc)", what is that?" merely goes to show that your small world view of what compiler's are allowed to do simply isn't big enough.
> such as CodeWarrior just does it right and does not bother with a warning,
You can't possibly tell the difference between "doing it right" and "accidentally producing the answer I expect". Do you even know what the warning is telling you? I bet your code is a bad of fun when you change compilers or compile debug and release modes, if that's your attitude.
Being a little bit undefined is the same as a little bit pregnant or a little bit dead - there is no such thing. It's an all or nothing deal. The fact that you've posted some really simple strawman expression which seems to prove your point doesn't wash - you have to consider all such expressions in whatever form they take (see later). You can't just pick "this one works" and "these don't".
You're also hung up on the difference between "what my compiler does" and "what the language guarantees". You can dig into the code for your compiler and prothelise all you want about the real world choices it makes, but it won't affect what any other compiler chooses to do.
Remeber -
Defined behaviour - every compiler will produce code which has the same effect.
Undefined behavior - you're on your own mate - good luck with that.
> Now here is the thing, Metrowerks CodeWarrior is a very respected compiler and it did not even issue a warning about it
There is no standard set of error messages, which is why for example gcc has many -W options, and why tools such as lint exist. If every compiler complained about every possible thing which could be determined from looking at the code, then very few people would make it past "hello world".
Here bright boy, analyse this minor variation on your theme.
Code:
#include <stdio.h>
int *f1 ( int *a ) { return a; }
#define f2(a) a
int main ( ) {
int a, b;
a = 1; b = 2;
*f1(&a) ^= *f1(&b) ^= *f1(&a) ^= *f1(&b);
printf( "%d %d\n", a, b );
a = 1; b = 2;
f2(a) ^= f2(b) ^= f2(a) ^= f2(b);
printf( "%d %d\n", a, b );
return 0;
}
Here's my output
Code:
$ gcc foo.c && ./a.out
0 1
2 1
Waaa!!!! where did my value go??
Welcome to the world of undefined behaviour.
And don't you dare back peddle into the "it only works in the simple case", because that's just admission that you really don't know what the ........ you're talking about.