3 ms·
My favorite UD in C is this: int x, y; x ^= y ^= x ^= y; I was using this for years until I realized that it is UD.
by utopcell 3y ago
My favorite UD in C is this:
int x, y;
x ^= y ^= x ^= y;
I was using this for years until I realized that it is UD.
- ryao 3y agoTwo assignments to the same variable in the same statement are undefined for the same reason i++ + ++i is undefined. That said, even if it were not, you did not define x and y. Reading them is also undefined behavior, which is what I initially though you meant until I read what followed them.