when the following code is compiled it goes into an infinite loop:
int main()
{
unsigned char ch;
FILE *fp;
fp = fopen(\"abc\",\"r\");
if(fp
There are several implicit conversions going on. They aren't really relevant to the specific warning, but I included them in this answer to show what the compiler really does with that expression.
So the expression is equivalent to
(unsigned char)ch != (int)EOF
The integer promotion rules in C will implicitly convert the unsigned char to unsigned int:
(unsigned int)ch != (int)EOF
Then the balancing rules (aka the usual arithmetic conversions) in C will implicitly convert the int to unsigned int, because each operand must have the same type:
(unsigned int)ch != (unsigned int)EOF
On your compiler EOF is likely -1:
(unsigned int)ch != (unsigned int)-1
which, assuming 32-bit CPU, is the same as
(unsigned int)ch != 0xFFFFFFFFu
A character can never have such a high value, hence the warning.