The following code has a subtle bug. Can you detect it?
DWORD ErrCode = GetLastError(); // Retrieve the error codeif (!ErrCode==ERROR_FILE_NOT_FOUND) // warning on this line
Although the compiler cannot guess the programmer’s intent, it issues a warning message that provides a cue:
warning C4806: '==' : unsafe operation: no value of type 'bool'
promoted to type 'const long' can equal the given constant.
The compiler says it cannot safely compare a variable of type bool and const long. Wait a minute