This project has moved. For the latest updates, please go here.


Runtime Check Error VS2010 Debug Builds


The code for splitting out the fileVersion information in the OnLoadModule code is throwing runtime checking exceptions for debug builds because the cast is occurring prior to the "& 0xFFFF" to blank out the higher order bits.
DWORD v4 = (DWORD) fileVersion & 0xFFFF;
DWORD v3 = (DWORD) (fileVersion>>16) & 0xFFFF;
DWORD v2 = (DWORD) (fileVersion>>32) & 0xFFFF;
DWORD v1 = (DWORD) (fileVersion>>48) & 0xFFFF;
DWORD v4 = (DWORD) (fileVersion & 0xFFFF);
DWORD v3 = (DWORD) ((fileVersion>>16) & 0xFFFF);
DWORD v2 = (DWORD) ((fileVersion>>32) & 0xFFFF);
DWORD v1 = (DWORD) ((fileVersion>>48) & 0xFFFF);


Microsoft Visual C++ Debug Library

Debug Error!
Program: ...
Module: ...
Run-Time Check Failure #1 - A cast to a smaller data type has caused a loss of data. If this was intentional, you should mask the source of the cast with the appropriate bitmask. For example:
char c = (i & 0xFF);
Changing the code in this way will not affect the quality of the resulting optimized code.
Closed Jan 7, 2013 at 9:38 AM by jkalmbach


jkalmbach wrote Jan 7, 2013 at 9:38 AM

Resolved with changeset 82071: "Runtime Check Error VS2010 Debug Builds" fixed