﻿# 64\-bit error

In our articles and documentation on [PVS\-Studio](https://pvs-studio.com/en/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:

```cpp
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](https://pvs-studio.com/en/blog/terms/0001/) 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](https://pvs-studio.com/en/blog/posts/cpp/a0065/)"\.

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](https://pvs-studio.com/en/blog/terms/0046/) Viva64 included into [PVS\-Studio](https://pvs-studio.com/en/pvs-studio/)\.

## References

1. Andrey Karpov\. [Are 64\-bit errors real?](https://pvs-studio.com/en/blog/posts/0030/)
1. Andrey Karpov\. [A Collection of Examples of 64\-bit Errors in Real Programs](https://pvs-studio.com/en/blog/posts/cpp/a0065/)\.
1. Andrey Karpov, Evgeniy Ryzhkov\. [20 issues of porting C\+\+ code on the 64\-bit platform](https://pvs-studio.com/en/blog/posts/cpp/a0004/)\.
1. Evgeniy Ryzhkov\. [Some examples of the 64\-bit code errors](https://pvs-studio.com/en/blog/posts/cpp/a0008/)\.
1. Andrey Karpov\. [64 bits, Wp64, Visual Studio 2008, Viva64 and all the rest\.\.\.](https://pvs-studio.com/en/blog/posts/cpp/a0021/)
1. Andrey Karpov\. [A 64\-bit horse that can count](https://pvs-studio.com/en/blog/posts/cpp/a0043/)\.
1. Andrey Karpov\. [Optimization in the world of 64\-bit errors](https://pvs-studio.com/en/blog/posts/cpp/0047/)\.
1. Andrey Karpov\. [A nice 64\-bit error in C](https://pvs-studio.com/en/blog/posts/cpp/0033/)\.