No need to do any of what I asked. The error is in the test itself:

As you said, the test runs as follows:

char inChar;

while ((inChar = fgetc(f)) != EOF)
  //do something

The problem stems from the fact that fgetc returns an int, not a char. This is 
for a very good reason: EOF is defined to (-1). Characters can be either signed 
or unsigned (the C standard leaves this choice up to the compiler if I 
remember well) and it seems tcc and gcc consider char as being unsigned. Thus, 
when the return value from fgetc is stored in inChar, it changes from -1 to 
255. Then, to do the comparison between inChar and EOF, the compiler will cast 
inChar in int because int is bigger than char. So you'll compare 255 to -1. If 
the int were to be casted down to char, then it'll work (as in comparing to 
(char) EOF).

I'll fix the test tomorrow.

Best regards,

Thomas

_______________________________________________
Tinycc-devel mailing list
Tinycc-devel@nongnu.org
https://lists.nongnu.org/mailman/listinfo/tinycc-devel

Reply via email to