Compiler Warning (level 1) C4311
'variable' : pointer truncation from 'type' to 'type'
This warning detects 64-bit portability issues. For example, if code is compiled on a 64-bit platform, the value of a pointer (64 bits) will be truncated if it is assigned to an int (32 bits).
This warning is only issued when /Wp64 is used. See /Wp64 for more information. Also, see Rules for Using Pointers.
For additional information on C4311, see Common Compiler Errors.
The following code sample generates C4311:
// C4311.cpp
// compile with: /W1 /Wp64
#include <stddef.h>
int main() {
void* p = &p;
unsigned long i = (unsigned long)p; // C4311
intptr_t j = (intptr_t)p; // OK
}