The purpose of this article is to answer some questions related to safe port of C/C++ code on 64-bit systems. The article is written as an answer to the topic often discussed on forums and related to the use of /Wp64 key and Viva64 tool.
/Wp64
Searching for explicit conversion of a pointer to a 32-bit type
In Visual Studio C++ compiler, there is the warning C4311 ('variable' : pointer truncation from 'type' to 'type') intended to detect errors of casting a pointer to 32-bit data types. This warning corresponds to warning #810 in Intel C++. This is an example of the defect they diagnose:
void *ptr = x; int y = (int)ptr;
Поиск явного приведения указателя к 32-битному типу
В компиляторе Visual Studio C++ имеется warning C4311 ('variable' : pointer truncation from 'type' to 'type') предназначенный для выявления ошибок приведения указателя к 32-битным типам данных. В Intel C++ этому предупреждению соответствует warning #810. Пример обнаруживаемого дефекта:
void *ptr = x; int y = (int)ptr;
Ключ /Wp64 и ошибка с обработкой шаблонов
Занимаясь продвижением анализатора Viva64 (из состава PVS-Studio) мы часто комментируем ключ /Wp64 из Microsoft Visual C++. Кто не в курсе, напомню, что этот ключ появился в Visual Studio 2003 и предназначался для подготовки миграции приложений на 64-битные системы. В Visual Studio 2008 ключ /Wp64 считается устаревшим, поскольку надо уже давно компилировать 64-битные приложения, а не готовиться к этому.
