Bitwise AND(&) has a lower precedence on the C Operator Precedence Table than logical does not equal(!=). Therefore, your original code is equivalent to:
Code:
if (disk & (0xF0 != 0xF0))
{
// code
}
You can see why the compiler takes the liberty of optimizing this out. As you have discovered you can use brackets to force the correct order of evaluation.
This is similar to the common problem with:
Code:
if (hFile = fopen("myfile", "r") == NULL)
which due to logical equals(==) having precedence over assignment(=) is equivalent to:
Code:
if (hFile = (fopen("myfile", "r") == NULL))