Prelude - that's quite a simple one, and the reason is due to this: The expression is broken down into two components that are evaluated left to right (I think, I never bothered to learn C's precedent rules):
((a == b) == c)
In your compiler's case the first truth test "a == b" will probably evaluate to 1 if true and 0 if false. So the expression is reduced to ((1) == c) if a was equal to b (which it was, because they're both 1). Then, because c is -1, the expression "((1) == c)" is obviously not true, so it comes up false.
It only worked with all the variables being 1 because that happened to co-incide with the truth value for your compiler which is also 1.
Truth operators are a bit funny to get used to in C,
, so try to deal with them on their own terms
- in other words, use (a == b && b == c).