Click on image to see enlargment
In order to help Santa, the elves decided to teleport toys thoughout the world. A recording of some gift is passed as standard input to this program and sent to two test cities. Why did Cairo receive only half a bicycle?
bug583.cpp lint Output
--- Module: bug583.cpp (C++) _ while( (ch = getchar()) != EOF ) bug583.cpp(16) : Info 734: Loss of precision (assignment) (31 bits to 7 bits) bug583.cpp(16) : Warning 583: Comparing type 'char' with EOF
Reference Manual Explanation
583 Comparing type 'Type' with EOF -- The message is issued when some form of character is compared against the EOF macro. EOF is normally defined to be -1. For example: while( (ch = getchar()) != EOF ) ... If ch is defined to be an int all is well. If however it is defined to be some form of char, then trouble might ensue. If ch is an unsigned char then it can never equal EOF. If ch is a signed char then you could get a premature termination because some data character happened to be all ones. Note that getchar returns an int. The reason it returns an int and not a char is because it must be capable of returning 257 different values (256 different characters plus EOF, assuming an 8-bit character). Once this value is assigned to a char only 256 values are then possible -- a clear loss of information.
If you have comments or questions about this bug, please post them to our Discussion Forum
Previous Bug - Bug #464 - November 2008