64-bit error

In our articles and documentation on PVS-Studio, this term means an error in C/C++ code that occurs when compiling the program in 64-bit mode. The code containing a 64-bit error correctly executes in 32-bit mode and causes a hang / access violation / slowdown / undefined behavior when launching the program built in the 64-bit configuration.

Here is an example:

float *Array = (float *)malloc(100 * sizeof(float));
float *ptr = Array + 50;
unsigned index = -1;
ptr[index] = 3.14f;

This code will lead to the error "Access Violation" on a 64-bit system. The value of index variable is 0xFFFFFFFFu and access to an item with this index is impossible. However, this code might have successfully worked for ten years in the 32-bit program where the operation ptr+0xFFFFFFFFu is equivalent to the operation ptr-1. Such errors are described more thoroughly in the article "A Collection of Examples of 64-bit Errors in Real Programs".

Those errors that we call "64-bit" may also show up on the systems whose architecture differs from Intel 64 / IA64. The code containing "64-bit errors" is often inefficient and incorrect and performs the actions it has been designed to perform only due to mere luck and peculiarities of the 32-bit architecture. The term "64-bit error" is introduced to single out the class of errors the programmer starts to encounter with while developing code for a 64-bit system or porting the existing 32-bit code to a 64-bit platform. It is possible to describe and diagnose the class of 64-bit errors at the stage of coding and therefore significantly reduce costs on testing and support of the 64-bit version of a software product. The diagnosis of this error class is implemented to the most extent in the static analyzer Viva64 included into PVS-Studio.


Bugs Found

Checked Projects
Collected Errors
14 526
This website uses cookies and other technology to provide you a more personalized experience. By continuing the view of our web-pages you accept the terms of using these files. If you don't want your personal data to be processed, please, leave this site. Learn More →