This is a standard gotcha in C operator precedence: == has higher precedence than ^, and so your expression is parsed as 3 ^ (1 == 1), which is indeed non-zero. To fix it, use explicit parentheses as follows: (3 ^ 1) == 1.
It would perhaps be nice if the C language had been defined differently (Wikipedia mentions this, for instance: https://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B#Criticism_of_bitwise_and_equality_operators_precedence), but we're stuck with it now, and GCC certainly cannot arbitrarily decide to change the language's operator precedence. ** Changed in: gcc-4.8 (Ubuntu) Status: New => Invalid -- You received this bug notification because you are a member of Ubuntu Bugs, which is subscribed to Ubuntu. https://bugs.launchpad.net/bugs/1533295 Title: Wrong result when comparing xor and int To manage notifications about this bug go to: https://bugs.launchpad.net/ubuntu/+source/gcc-4.8/+bug/1533295/+subscriptions -- ubuntu-bugs mailing list [email protected] https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs
