V580. An odd explicit type casting. Consider verifying it.


The analyzer detected an odd explicit type conversion. It may be either an error or a potential error.

Consider this sample:

DWORD errCode = 0;
void* dwErrParams[MAX_MESSAGE_PARAMS];
dwErrParams[0] = *((void**)&errCode);

The code contains a 64-bit error. The 'DWORD' type is cast to 'void *' type. This code works incorrectly in 64-bit systems where the pointer's size does not coincide with the size of the DWORD type. This is the correct code:

DWORD_PTR errCode = 0;
void* dwErrParams[MAX_MESSAGE_PARAMS];
dwErrParams[0] = (void *)errCode;

According to Common Weakness Enumeration, potential errors found by using this diagnostic are classified as CWE-843.


Bugs Found

Checked Projects
364
Collected Errors
13 504