SlideShare uma empresa Scribd logo
1 de 22
Baixar para ler offline
Some examples of the 64-bit code errors
Author: Evgeniy Ryzhkov

Date: 23.07.2007


Abstract
While porting 32-bit software to 64-bit systems there may appear some errors in the code of
applications which were written in C++ language. The cause for these hides in the alteration of the base
data types (to be more exact, in the relations between them) with the new hardware platform.

This article contains various examples of 64-bit errors. However, we have learnt much more examples
and types of errors since we started writing the article and they were not included into it. Please see the
article "A Collection of Examples of 64-bit Errors in Real Programs" that covers defects in 64-bit
programs we know of most thoroughly. We also recommend you to study the course "Lessons on
development of 64-bit C/C++ applications" where we describe the methodology of creating correct 64-
bit code and searching for all types of defects using the Viva64 code analyzer.


Introduction
While porting 32-bit software to 64-bit systems there may appear some errors in the code of
applications which were written in C++ language. The cause for these hides in the alteration of the base
data types (to be more exact, in the relations between them) with the new hardware platform. "But isn't
C++ a high-level language!" you may ask, and you will be right. But still all the high-level abstractions are
realized through the low-level data types.

Help documentation for developers is sure to contain the description of such errors. However, even
such authoritative sources as, for example MSDN, often give only platitudes, for instance:

    •   int and long remained 32-bit ones with 64-bit versions of Widows;
    •   size_t, time_t, and ptrdiff_t became 64-bit ones with 64-bit versions of Windows.

But what does it mean for a developer and what problems may it potentially cause - all this is not
reported in the help.

Meanwhile, there are very few articles which contain certain examples of application code errors in 64-
bit Windows versions. This article is to fill the vacuum.

First of all some terminology. Memsize type is any data type which changes its size when the digit
capacity of architecture is changed from 32 bits to 64 bits. The examples are size_t, ptrdiff_t,
DWORD_PTR, LONG_PTR and others.

Take a note that only short examples of errors are given in the article. The explanation of their causes
are given in the article "20 issues of porting C++ of porting C++ code on the 64-bit platform"
http://www.viva64.com/art-1-2-599168895.html .
An error source code example
Let us not harass the developers who wish to get down to studying the error examples, so let's show the
whole source code of such a program. After the source code each error will be considered separately.

To demonstrate the errors it is necessary to compile and run this code in the 64-bit mode.

You can find the source code of an application which contains this code in a Viva64 distributive named
PortSample. For this purpose download and install Viva64 (www.viva64.com/download.php) and then
install PortSamle from program folder Viva64.

bool IsX64Platform() {

    return sizeof(size_t) == 8;

}

template <typename A, typename B>

inline size_t SafeMul(A a, B b) {

    return static_cast<size_t>(a) * static_cast<size_t>(b);

}

template <typename A, typename B, typename C>

inline size_t SafeMul(A a, B b, C c) {

    return static_cast<size_t>(a) * static_cast<size_t>(b) *

     static_cast<size_t>(c);

}

template <typename A, typename B, typename C, typename D>

inline size_t SafeMul(A a, B b, C c, D d) {

    return static_cast<size_t>(a) * static_cast<size_t>(b) *

             static_cast<size_t>(c) * static_cast<size_t>(d);

}

void V101()

{

    unsigned imageWidth = 1000;

    unsigned imageHeght = 1000;

    unsigned bytePerPixel = 3;

    unsigned maxFrameCountInBuffer;

    if (IsX64Platform()) {
maxFrameCountInBuffer = 2000;

    } else {

        maxFrameCountInBuffer = 100;

    }

    size_t bufferSize = imageWidth * imageHeght *

                          bytePerPixel * maxFrameCountInBuffer;

    BYTE *buffer = static_cast<BYTE *>(malloc(bufferSize));

    BYTE *ptr = buffer;

    for (unsigned frame = 0; frame != maxFrameCountInBuffer; ++frame)

        for (unsigned width = 0; width != imageWidth; ++width)

         for (unsigned height = 0; height != imageHeght; ++height) {

             *ptr++ = 0xFF;

             *ptr++ = 0xFF;

             *ptr++ = 0x00;

         }

    free (buffer);

}

void V102()

{

    int domainWidth;

    int domainHeght;

    int domainDepth;

    if (IsX64Platform()) {

        domainWidth = 2000;

        domainHeght = 2000;

        domainDepth = 2000;

    } else {

        domainWidth = 500;

        domainHeght = 500;

        domainDepth = 500;
}



    char *buffer =

    new char [size_t(domainWidth) * size_t(domainHeght) *
size_t(domainDepth)];



    char *current = buffer;

    char *end = buffer;

    end += domainWidth * domainHeght * domainDepth;

    while (current != end)

        *current++ = 1;

    delete [] buffer;

}

void V103()

{

    size_t Megabyte = 1048576;

    size_t Gigabyte = 1073741824;

    size_t n = IsX64Platform() ? Gigabyte : Megabyte;

    unsigned arraySize = n * sizeof(INT_PTR);

    INT_PTR *buffer = (INT_PTR *)malloc(size_t(arraySize));

    for (size_t i = 0; i != n; ++i)

        buffer[i] = 0;

    free(buffer);

}

void V104()

{

    volatile size_t n;

    if (IsX64Platform()) {

        n = SafeMul(5, 1024, 1024, 1024);

    } else {
n = SafeMul(5, 1024, 1024);

    }



    char *buffer = new char [n];



    volatile size_t index = 0;

    volatile unsigned i;

    for (i = 0; i != n; ++i)

        buffer[index++] = 1;

    delete [] buffer;

}

void V105()

{

    bool flag = true;

    unsigned a = unsigned(-1);

    if ((flag ? a : sizeof(float)) != size_t(-1)) {

        throw CString("x64 portability issues");

    }

}

void V106()

{

    void *buffer;

    const unsigned Megabyte = 1024 * 1024;

    const unsigned Gigabyte = 1024 * 1024 * 1024;

    unsigned unit;

    if (IsX64Platform())

        unit = Gigabyte;

    else

        unit = Megabyte;

    buffer = malloc(5 * unit);
if (IsX64Platform())

        memset(buffer, 0, SafeMul(5, 1024, 1024, 1024));

    else

        memset(buffer, 0, SafeMul(5, 1024, 1024));

    free(buffer);

}

void V107_FillFunction(char *array, unsigned arraySize) {

    for (unsigned i = 0; i != arraySize; ++i)

        array[i] = 1;

}

void V107()

{

    size_t n;

    if (IsX64Platform()) {

        n = SafeMul(5, 1024, 1024, 1024);

    } else {

        n = SafeMul(5, 1024, 1024);

    }

    char *array = (char *)malloc(n * sizeof(char));

    memset(array, 0, n * sizeof(char));

    V107_FillFunction(array, n);

    for (size_t i = 0; i != n; ++i)

        if (array[i] != 1)

         throw CString("x64 portability issues");

    free(array);

}

void V108()

{

    size_t n;

    if (IsX64Platform()) {
n = SafeMul(5, 1024, 1024, 1024);

    } else {

        n = SafeMul(5, 1024, 1024);

    }

    char *array = (char *)malloc(n * sizeof(char));

    memset(array, 0, n * sizeof(char));

    volatile int index = 0;

    for (size_t i = 0; i != n; ++i) {

        array[index++] = 1;

        if (array[i] != 1)

         throw CString("x64 portability issues");

    }

    free(array);

}

ptrdiff_t UnsafeCalcIndex(int x, int y, int width) {

    volatile int result = x + y * width;

    return result;

}

void V109()

{

    int domainWidth;

    int domainHeght;

    if (IsX64Platform()) {

        domainWidth = 50000;

        domainHeght = 50000;

    } else {

        domainWidth = 5000;

        domainHeght = 5000;

    }

    char *array = (char *)malloc(SafeMul(domainWidth, domainHeght));
for (int x = 0; x != domainWidth; ++x)

        for (int y = 0; y != domainHeght; ++y) {

            array[UnsafeCalcIndex(x, y, domainWidth)] = 55;

        }

    free(array);

}

int UnsafeStrLen(const char *text) {

    const char *ptr = text;

    while (*ptr != 0)

        ++ptr;

    return ptr - text;

}

void V110()

{

    size_t n;

    CString trueSize;

    if (IsX64Platform()) {

        n = SafeMul(3, 1024, 1024, 1024);

        trueSize = _T("3221225472");

    } else {

        n = SafeMul(3, 1024, 1024);

        trueSize = _T("3145728");

    }

    char *str = (char *)malloc(n * sizeof(char));

    memset(str, 'V', n * sizeof(char));

    str[n - 1] = 0;

    int len = UnsafeStrLen(str);

    CString falseSize;

    falseSize.Format(_T("%i"), len + 1);

    free(str);
if (falseSize != trueSize)

     throw CString(_T("x64 portability issues"));

}

void V111()

{

    char invalidStr[100], validStr[100];

    const char *invalidFormat = "%u";

    const char *validFormat = "%Iu";

    size_t a = SIZE_MAX;

    sprintf_s(invalidStr, sizeof(invalidStr),invalidFormat, a);

    sprintf_s(validStr, sizeof(validStr), validFormat, a);

    if (strcmp(invalidStr, validStr) != 0)

     throw CString(_T("x64 portability issues"));

}

void V113()

{

    size_t a = size_t(-1);

    double b = a;

    --a;

    --b;

    size_t c = b;

    if (a != c)

     throw CString(_T("x64 portability issues"));

}

void V114()

{

    unsigned intPtr[10] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };

    size_t *sizetPtr = (size_t *)(intPtr);

    size_t sum = 0;

    for (size_t i = 0; i != 10; ++i)
sum += sizetPtr[i];

    if (sum != 45)

     throw CString(_T("x64 portability issues"));

}

void V301()

{

    class CWinAppTest {

    public:

     virtual void WinHelp(DWORD_PTR, UINT) {

         ::AfxMessageBox(_T("Cannot activate WinHelp"));

     }

    };

    class CPortSampleApp : public CWinAppTest {

    public:

     virtual void WinHelp(DWORD, UINT) {

         ::AfxMessageBox(_T("WinHelp activated"));

     }

    };

    CWinAppTest *Application = new CPortSampleApp();

    Application->WinHelp(NULL, 0);

    delete Application;

}

int _tmain(int argc, TCHAR* argv[])

{

    V101();

    V102();

    V103();

    V104();

    V105();

    V106();
V107();

    V108();

    V109();

    V110();

    V111();

    V112();

    V113();

    V114();

    V201();

    V202();

    V203();

    V301();

    return 0;

}

Now, when we see the whole code, let's consider the functions which contain errors. When we say that
a function contains an error we mean the following: the given code is able to compile and function in
the 32-bit regime, but after compiling for the64-bit regime its functioning becomes incorrect up to fall.


Implicit conversion to memsize type
void V101()

{

    unsigned imageWidth = 1000;

    unsigned imageHeght = 1000;

    unsigned bytePerPixel = 3;

    unsigned maxFrameCountInBuffer;

    if (IsX64Platform()) {

        maxFrameCountInBuffer = 2000;

    } else {

        maxFrameCountInBuffer = 100;

    }

    size_t bufferSize = imageWidth * imageHeght *
bytePerPixel * maxFrameCountInBuffer;

    BYTE *buffer = static_cast<BYTE *>(malloc(bufferSize));

    BYTE *ptr = buffer;

    for (unsigned frame = 0; frame != maxFrameCountInBuffer; ++frame)

      for (unsigned width = 0; width != imageWidth; ++width)

         for (unsigned height = 0; height != imageHeght; ++height) {

             *ptr++ = 0xFF;

             *ptr++ = 0xFF;

             *ptr++ = 0x00;

         }

    free (buffer);

}

The problem is in the next line:

size_t bufferSize = imageWidth * imageHeght *

                                   bytePerPixel * maxFrameCountInBuffer;

All the varibles in the multiplation are of unsigned type, which in both 32-bit and 64-bit regimes
pssesses the sie of 32 bits. But the result of multiplation is written with a variable of size_t type which in
the 32-bit mode possesses the size coinciding with the size of unsigned type and they don't coincide in
the 64-bit mode. But the compiler fulfills the extention of the result type up to unsigned one.It seems
that there is no problem at all. But the problem exists! If the result of multplication exceeds 4 gigabytes
the overflow will occur and the result will be incorrect.


The use of non-memsize types for the pointers arithmetic
void V102()

{

    int domainWidth;

    int domainHeght;

    int domainDepth;

    if (IsX64Platform()) {

      domainWidth = 2000;

      domainHeght = 2000;

      domainDepth = 2000;
} else {

        domainWidth = 500;

        domainHeght = 500;

        domainDepth = 500;

    }



    char *buffer =

    new char [size_t(domainWidth) * size_t(domainHeght) *
size_t(domainDepth)];



    char *current = buffer;

    char *end = buffer;

    end += domainWidth * domainHeght * domainDepth;

    while (current != end)

        *current++ = 1;

    delete [] buffer;

}

The problem in the given code is the pointers arithmetic, to be more exact, the use of non-memsize
types for this arithmetic:

    end += domainWidth * domainHeght * domainDepth;

The error is that with the 64-bit platform the pointer end will never have the increment larger than 4
gigabytes.


Implicit conversion of memsize type
void V103()

{

    size_t Megabyte = 1048576;

    size_t Gigabyte = 1073741824;

    size_t n = IsX64Platform() ? Gigabyte : Megabyte;

    unsigned arraySize = n * sizeof(INT_PTR);

    INT_PTR *buffer = (INT_PTR *)malloc(size_t(arraySize));

    for (size_t i = 0; i != n; ++i)
buffer[i] = 0;

    free(buffer);

}

There is an obvious error in the following code fragment.

    unsigned arraySize = n * sizeof(INT_PTR);

It's the implicit conversion to the unsigned type of a variable of larger capacity (on a 64-bit platform).


Implicit conversion to memsize type in an arithmetic sentence
void V104()

{

    volatile size_t n;

    if (IsX64Platform()) {

        n = SafeMul(5, 1024, 1024, 1024);

    } else {

        n = SafeMul(5, 1024, 1024);

    }



    char *buffer = new char [n];



    volatile size_t index = 0;

    volatile unsigned i;

    for (i = 0; i != n; ++i)

        buffer[index++] = 1;

    delete [] buffer;

}

It's strange but operations of comparing two variables may be also the source of trouble. In the
following line

    for (i = 0; i != n; ++i)

the problem is that the variable i of unsigned type is compared to the variable n of size_t type, and after
that this variable extends. But as unsigned never exceeds 4 gigabytes , than i will never be larger than
this value. What do we have as a result? We have an infinite loop! as the conditions of i != n will always
be fulfilled.
Implicit conversion to memsize type in ?: operation
void V105()

{

    bool flag = true;

    unsigned a = unsigned(-1);

    if ((flag ? a : sizeof(float)) != size_t(-1)) {

        throw CString("x64 portability issues");

    }

}

This example is very much alike to the previous one, the problem can be found in the following line:

    if ((flag ? a : sizeof(float)) != size_t(-1)) {

here the variable a is of unsigned type which may give an incorrect result when compared to size_t.
Why? Just because unsigned(-1) is not equal to size_t (-1).


Implicit conversion of a function argument to memsize type
void V106()

{

    void *buffer;

    const unsigned Megabyte = 1024 * 1024;

    const unsigned Gigabyte = 1024 * 1024 * 1024;

    unsigned unit;

    if (IsX64Platform())

        unit = Gigabyte;

    else

        unit = Megabyte;

    buffer = malloc(5 * unit);

    if (IsX64Platform())

        memset(buffer, 0, SafeMul(5, 1024, 1024, 1024));

    else

        memset(buffer, 0, SafeMul(5, 1024, 1024));

    free(buffer);
}

In the line

    buffer = malloc(5 * unit);

the developer hoped to get a 5-gigabyte buffer with a 64-bit system. But an error will occur here. You
ask why? Just because the malloc() function possesses an argument of memsize type and 5 is quite an
appropriate value. But when (5 * unit) is multiplied an overflow will occur because the unit variable is of
unsigned type. The result will for sure be not 5 gigabytes.


Implicit conversion of a function argument of memsize type to the 32-bit
type
void V107_FillFunction(char *array, unsigned arraySize) {

    for (unsigned i = 0; i != arraySize; ++i)

        array[i] = 1;

}

void V107()

{

    size_t n;

    if (IsX64Platform()) {

        n = SafeMul(5, 1024, 1024, 1024);

    } else {

        n = SafeMul(5, 1024, 1024);

    }

    char *array = (char *)malloc(n * sizeof(char));

    memset(array, 0, n * sizeof(char));

    V107_FillFunction(array, n);

    for (size_t i = 0; i != n; ++i)

        if (array[i] != 1)

         throw CString("x64 portability issues");

    free(array);

}

In the line with function call

    V107_FillFunction(array, n);
there occurs the conversion of type of the variable n to unsigned. This means truncation of the variable
value, the result of this is that not the whole array is filled.


The use of incorrect types for indexation
void V108()

{

    size_t n;

    if (IsX64Platform()) {

        n = SafeMul(5, 1024, 1024, 1024);

    } else {

        n = SafeMul(5, 1024, 1024);

    }

    char *array = (char *)malloc(n * sizeof(char));

    memset(array, 0, n * sizeof(char));

    volatile int index = 0;

    for (size_t i = 0; i != n; ++i) {

        array[index++] = 1;

        if (array[i] != 1)

         throw CString("x64 portability issues");

    }

    free(array);

}

If not a memsize type is used for array indexation, it is possible that there will occur an error like the
following:

array[index++] = 1;

The problem is the following: in case if there are more than 4 gigabytes of elements , you may not use
the variable of unsigned type.


Conversion to memsize type using a return value
ptrdiff_t UnsafeCalcIndex(int x, int y, int width) {

    volatile int result = x + y * width;

    return result;
}

void V109()

{

    int domainWidth;

    int domainHeght;

    if (IsX64Platform()) {

        domainWidth = 50000;

        domainHeght = 50000;

    } else {

        domainWidth = 5000;

        domainHeght = 5000;

    }

    char *array = (char *)malloc(SafeMul(domainWidth, domainHeght));

    for (int x = 0; x != domainWidth; ++x)

        for (int y = 0; y != domainHeght; ++y) {

            array[UnsafeCalcIndex(x, y, domainWidth)] = 55;

        }

    free(array);

}

It's amazing, but in this example the error is in the line:

    return result;

The value result is of int type which will be implicitly expanded to ptrdiff_t. But the function
UnsafeCalcIndex() will never be able to return the index of the element following 2 gigabytes. It would
be more correct to say that the error is the wrongly chosen type of the variable result. In this case this
variable must be of UnsafeCalcIndex() type.


Conversion of memsize type using a return value
int UnsafeStrLen(const char *text) {

    const char *ptr = text;

    while (*ptr != 0)

        ++ptr;

    return ptr - text;
}

void V110()

{

    size_t n;

    CString trueSize;

    if (IsX64Platform()) {

        n = SafeMul(3, 1024, 1024, 1024);

        trueSize = _T("3221225472");

    } else {

        n = SafeMul(3, 1024, 1024);

        trueSize = _T("3145728");

    }

    char *str = (char *)malloc(n * sizeof(char));

    memset(str, 'V', n * sizeof(char));

    str[n - 1] = 0;

    int len = UnsafeStrLen(str);

    CString falseSize;

    falseSize.Format(_T("%i"), len + 1);

    if (falseSize != trueSize)

        throw CString(_T("x64 portability issues"));

}

The situation is the same as in the previous example and the error is again in the line of the return value:

    return ptr - text;

The difference is that here we deal with the conversion of memsize type to int type. The result is that
the buffer size (from the example) will never be figured out if it is larger than 2 gigabytes.


Call of function with variable number of arguments with memsize
parameter
void V111()

{

    char invalidStr[100], validStr[100];
const char *invalidFormat = "%u";

    const char *validFormat = "%Iu";

    size_t a = SIZE_MAX;

    sprintf_s(invalidStr, sizeof(invalidStr),invalidFormat, a);

    sprintf_s(validStr, sizeof(validStr), validFormat, a);

    if (strcmp(invalidStr, validStr) != 0)

      throw CString(_T("x64 portability issues"));

}

Functions with variable number of arguments are often used for formatting and input/output of text
lines. Incorrect presetting of the format line may cause incorrect work.

    const char *invalidFormat = "%u";

    sprintf_s(invalidStr, sizeof(invalidStr),invalidFormat, a);

The format line in this example is estimated for 32-bit mode of working and in 64-bit mode it will cause
incorrect output.


Implicit conversion of memsize type to double and vice versa
void V113()

{

    size_t a = size_t(-1);

    double b = a;

    --a;

    --b;

    size_t c = b;

    if (a != c)

      throw CString(_T("x64 portability issues"));

}

In this example there are errors in two lines:

double b = a;

and

size_t c = b;

Such asignment with 64-bit systems is incorrect because it may cause loss of preision.
Explicit type conversion if the course of work with pointers
void V114()

{

    unsigned intPtr[10] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };

    size_t *sizetPtr = (size_t *)(intPtr);

    size_t sum = 0;

    for (size_t i = 0; i != 10; ++i)

     sum += sizetPtr[i];

    if (sum != 45)

     throw CString(_T("x64 portability issues"));

}

C++ being a low-level language allows working with memory at the pointer level. Explicit type
conversion using pointers is anyway dangerous, but conversion of memsize types , as shown in the
example, is twice dangerous.

    size_t *sizetPtr = (size_t *)(intPtr);

The matter is the difference of types size_t and unsigned.


Overriding virtual functions
void V301()

{

    class CWinAppTest {

    public:

     virtual void WinHelp(DWORD_PTR, UINT) {

         ::AfxMessageBox(_T("Cannot activate WinHelp"));

     }

    };

    class CPortSampleApp : public CWinAppTest {

    public:

     virtual void WinHelp(DWORD, UINT) {

         ::AfxMessageBox(_T("WinHelp activated"));

     }
};

    CWinAppTest *Application = new CPortSampleApp();

    Application->WinHelp(NULL, 0);

    delete Application;

}

One of the funniest errors of C++ applications which can appear with 64-bit systems is related to virtual
functions. Pay your attention to the parameters of virtual functions in the example above. With a 32-bit
system DWORD_PTR and DWORD coincide and there appears an overridden virtual function, and with a
64-bit platform there are two different functions! As a result the call of WinHelp() function from the
example will cause the appearance of "Cannot activate WinHelp" message.


Pro conclusion
Thus, we have listed all the main code errors which appear when a code is ported to 64-bit systems. You
might think many of them are sophisticated. For example, who, for God's sake, may need a 5 gigabyte
buffer at Windows system? Maybe this problem is not very acute in 2007, though many resource-
intensive applications are already able to use such amount of memory. We'll see if this article will be
actual in a couple of years. Maybe just you will debug an error which appears when several gigabytes of
memory are allocated.


Some information about the author
Evgeniy Ryzhkov is one of the developers of the static code analyzer Viva64 which is meant for
simplifying the migration of applications to 64-bit platforms. He studies the migration of 32-bit program
systems to 64-bit platforms.

Mais conteúdo relacionado

Mais procurados

Advance features of C++
Advance features of C++Advance features of C++
Advance features of C++vidyamittal
 
CUDA First Programs: Computer Architecture CSE448 : UAA Alaska : Notes
CUDA First Programs: Computer Architecture CSE448 : UAA Alaska : NotesCUDA First Programs: Computer Architecture CSE448 : UAA Alaska : Notes
CUDA First Programs: Computer Architecture CSE448 : UAA Alaska : NotesSubhajit Sahu
 
Introduce to Rust-A Powerful System Language
Introduce to Rust-A Powerful System LanguageIntroduce to Rust-A Powerful System Language
Introduce to Rust-A Powerful System Language安齊 劉
 
Microsoft Word Hw#1
Microsoft Word   Hw#1Microsoft Word   Hw#1
Microsoft Word Hw#1kkkseld
 
Rainer Grimm, “Functional Programming in C++11”
Rainer Grimm, “Functional Programming in C++11”Rainer Grimm, “Functional Programming in C++11”
Rainer Grimm, “Functional Programming in C++11”Platonov Sergey
 
Torturing the PHP interpreter
Torturing the PHP interpreterTorturing the PHP interpreter
Torturing the PHP interpreterLogicaltrust pl
 
To Swift 2...and Beyond!
To Swift 2...and Beyond!To Swift 2...and Beyond!
To Swift 2...and Beyond!Scott Gardner
 
Computer graphics File for Engineers
Computer graphics File for EngineersComputer graphics File for Engineers
Computer graphics File for Engineersvarun arora
 
Senior design project code for PPG
Senior design project code for PPGSenior design project code for PPG
Senior design project code for PPGFrankDin1
 
Java binary subtraction
Java binary subtractionJava binary subtraction
Java binary subtractionCharm Sasi
 
ExperiencesSharingOnEmbeddedSystemDevelopment_20160321
ExperiencesSharingOnEmbeddedSystemDevelopment_20160321ExperiencesSharingOnEmbeddedSystemDevelopment_20160321
ExperiencesSharingOnEmbeddedSystemDevelopment_20160321Teddy Hsiung
 
Guaranteeing Memory Safety in Rust
Guaranteeing Memory Safety in RustGuaranteeing Memory Safety in Rust
Guaranteeing Memory Safety in Rustnikomatsakis
 
GPU Programming on CPU - Using C++AMP
GPU Programming on CPU - Using C++AMPGPU Programming on CPU - Using C++AMP
GPU Programming on CPU - Using C++AMPMiller Lee
 
Story of static code analyzer development
Story of static code analyzer developmentStory of static code analyzer development
Story of static code analyzer developmentAndrey Karpov
 
20140531 serebryany lecture01_fantastic_cpp_bugs
20140531 serebryany lecture01_fantastic_cpp_bugs20140531 serebryany lecture01_fantastic_cpp_bugs
20140531 serebryany lecture01_fantastic_cpp_bugsComputer Science Club
 

Mais procurados (18)

Advance features of C++
Advance features of C++Advance features of C++
Advance features of C++
 
AA-sort with SSE4.1
AA-sort with SSE4.1AA-sort with SSE4.1
AA-sort with SSE4.1
 
CUDA First Programs: Computer Architecture CSE448 : UAA Alaska : Notes
CUDA First Programs: Computer Architecture CSE448 : UAA Alaska : NotesCUDA First Programs: Computer Architecture CSE448 : UAA Alaska : Notes
CUDA First Programs: Computer Architecture CSE448 : UAA Alaska : Notes
 
Introduce to Rust-A Powerful System Language
Introduce to Rust-A Powerful System LanguageIntroduce to Rust-A Powerful System Language
Introduce to Rust-A Powerful System Language
 
Computing on Encrypted Data
Computing on Encrypted DataComputing on Encrypted Data
Computing on Encrypted Data
 
Microsoft Word Hw#1
Microsoft Word   Hw#1Microsoft Word   Hw#1
Microsoft Word Hw#1
 
Rainer Grimm, “Functional Programming in C++11”
Rainer Grimm, “Functional Programming in C++11”Rainer Grimm, “Functional Programming in C++11”
Rainer Grimm, “Functional Programming in C++11”
 
Torturing the PHP interpreter
Torturing the PHP interpreterTorturing the PHP interpreter
Torturing the PHP interpreter
 
To Swift 2...and Beyond!
To Swift 2...and Beyond!To Swift 2...and Beyond!
To Swift 2...and Beyond!
 
Computer graphics File for Engineers
Computer graphics File for EngineersComputer graphics File for Engineers
Computer graphics File for Engineers
 
C programs
C programsC programs
C programs
 
Senior design project code for PPG
Senior design project code for PPGSenior design project code for PPG
Senior design project code for PPG
 
Java binary subtraction
Java binary subtractionJava binary subtraction
Java binary subtraction
 
ExperiencesSharingOnEmbeddedSystemDevelopment_20160321
ExperiencesSharingOnEmbeddedSystemDevelopment_20160321ExperiencesSharingOnEmbeddedSystemDevelopment_20160321
ExperiencesSharingOnEmbeddedSystemDevelopment_20160321
 
Guaranteeing Memory Safety in Rust
Guaranteeing Memory Safety in RustGuaranteeing Memory Safety in Rust
Guaranteeing Memory Safety in Rust
 
GPU Programming on CPU - Using C++AMP
GPU Programming on CPU - Using C++AMPGPU Programming on CPU - Using C++AMP
GPU Programming on CPU - Using C++AMP
 
Story of static code analyzer development
Story of static code analyzer developmentStory of static code analyzer development
Story of static code analyzer development
 
20140531 serebryany lecture01_fantastic_cpp_bugs
20140531 serebryany lecture01_fantastic_cpp_bugs20140531 serebryany lecture01_fantastic_cpp_bugs
20140531 serebryany lecture01_fantastic_cpp_bugs
 

Destaque

Knee-deep in C++ s... code
Knee-deep in C++ s... codeKnee-deep in C++ s... code
Knee-deep in C++ s... codePVS-Studio
 
In what way can C++0x standard help you eliminate 64-bit errors
In what way can C++0x standard help you eliminate 64-bit  errorsIn what way can C++0x standard help you eliminate 64-bit  errors
In what way can C++0x standard help you eliminate 64-bit errorsPVS-Studio
 
Interview with Dmitriy Vyukov - the author of Relacy Race Detector (RRD)
Interview with Dmitriy Vyukov - the author of Relacy Race Detector (RRD)Interview with Dmitriy Vyukov - the author of Relacy Race Detector (RRD)
Interview with Dmitriy Vyukov - the author of Relacy Race Detector (RRD)PVS-Studio
 
Viva64: What Is It, and Who Is It for?
Viva64: What Is It, and Who Is It for?Viva64: What Is It, and Who Is It for?
Viva64: What Is It, and Who Is It for?PVS-Studio
 
Problems of testing 64-bit applications
Problems of testing 64-bit applicationsProblems of testing 64-bit applications
Problems of testing 64-bit applicationsPVS-Studio
 
Traps detection during migration of C and C++ code to 64-bit Windows
Traps detection during migration of C and C++ code to 64-bit WindowsTraps detection during migration of C and C++ code to 64-bit Windows
Traps detection during migration of C and C++ code to 64-bit WindowsPVS-Studio
 
Static code analysis for verification of the 64-bit applications
Static code analysis for verification of the 64-bit applicationsStatic code analysis for verification of the 64-bit applications
Static code analysis for verification of the 64-bit applicationsPVS-Studio
 
Lesson 13. Pattern 5. Address arithmetic
Lesson 13. Pattern 5. Address arithmeticLesson 13. Pattern 5. Address arithmetic
Lesson 13. Pattern 5. Address arithmeticPVS-Studio
 
About size_t and ptrdiff_t
About size_t and ptrdiff_tAbout size_t and ptrdiff_t
About size_t and ptrdiff_tPVS-Studio
 
Lesson 11. Pattern 3. Shift operations
Lesson 11. Pattern 3. Shift operationsLesson 11. Pattern 3. Shift operations
Lesson 11. Pattern 3. Shift operationsPVS-Studio
 
Analysis of the Ultimate Toolbox project
Analysis of the Ultimate Toolbox projectAnalysis of the Ultimate Toolbox project
Analysis of the Ultimate Toolbox projectPVS-Studio
 
PVS-Studio vs Chromium
PVS-Studio vs ChromiumPVS-Studio vs Chromium
PVS-Studio vs ChromiumPVS-Studio
 
Intel IPP Samples for Windows - error correction
Intel IPP Samples for Windows - error correctionIntel IPP Samples for Windows - error correction
Intel IPP Samples for Windows - error correctionPVS-Studio
 
Optimization in the world of 64-bit errors
Optimization  in the world of 64-bit errorsOptimization  in the world of 64-bit errors
Optimization in the world of 64-bit errorsPVS-Studio
 
How VivaCore library appeared
How VivaCore library appearedHow VivaCore library appeared
How VivaCore library appearedPVS-Studio
 
Debugging and optimization of multi-thread OpenMP-programs
Debugging and optimization of multi-thread OpenMP-programsDebugging and optimization of multi-thread OpenMP-programs
Debugging and optimization of multi-thread OpenMP-programsPVS-Studio
 
Interview with Anatoliy Kuznetsov, the author of BitMagic C++ library
Interview with Anatoliy Kuznetsov, the author of BitMagic C++ libraryInterview with Anatoliy Kuznetsov, the author of BitMagic C++ library
Interview with Anatoliy Kuznetsov, the author of BitMagic C++ libraryPVS-Studio
 
Changes in programmer tools' infrastructure
Changes in programmer tools' infrastructureChanges in programmer tools' infrastructure
Changes in programmer tools' infrastructurePVS-Studio
 
Lesson 21. Pattern 13. Data alignment
Lesson 21. Pattern 13. Data alignmentLesson 21. Pattern 13. Data alignment
Lesson 21. Pattern 13. Data alignmentPVS-Studio
 
Regular use of static code analysis in team development
Regular use of static code analysis in team developmentRegular use of static code analysis in team development
Regular use of static code analysis in team developmentPVS-Studio
 

Destaque (20)

Knee-deep in C++ s... code
Knee-deep in C++ s... codeKnee-deep in C++ s... code
Knee-deep in C++ s... code
 
In what way can C++0x standard help you eliminate 64-bit errors
In what way can C++0x standard help you eliminate 64-bit  errorsIn what way can C++0x standard help you eliminate 64-bit  errors
In what way can C++0x standard help you eliminate 64-bit errors
 
Interview with Dmitriy Vyukov - the author of Relacy Race Detector (RRD)
Interview with Dmitriy Vyukov - the author of Relacy Race Detector (RRD)Interview with Dmitriy Vyukov - the author of Relacy Race Detector (RRD)
Interview with Dmitriy Vyukov - the author of Relacy Race Detector (RRD)
 
Viva64: What Is It, and Who Is It for?
Viva64: What Is It, and Who Is It for?Viva64: What Is It, and Who Is It for?
Viva64: What Is It, and Who Is It for?
 
Problems of testing 64-bit applications
Problems of testing 64-bit applicationsProblems of testing 64-bit applications
Problems of testing 64-bit applications
 
Traps detection during migration of C and C++ code to 64-bit Windows
Traps detection during migration of C and C++ code to 64-bit WindowsTraps detection during migration of C and C++ code to 64-bit Windows
Traps detection during migration of C and C++ code to 64-bit Windows
 
Static code analysis for verification of the 64-bit applications
Static code analysis for verification of the 64-bit applicationsStatic code analysis for verification of the 64-bit applications
Static code analysis for verification of the 64-bit applications
 
Lesson 13. Pattern 5. Address arithmetic
Lesson 13. Pattern 5. Address arithmeticLesson 13. Pattern 5. Address arithmetic
Lesson 13. Pattern 5. Address arithmetic
 
About size_t and ptrdiff_t
About size_t and ptrdiff_tAbout size_t and ptrdiff_t
About size_t and ptrdiff_t
 
Lesson 11. Pattern 3. Shift operations
Lesson 11. Pattern 3. Shift operationsLesson 11. Pattern 3. Shift operations
Lesson 11. Pattern 3. Shift operations
 
Analysis of the Ultimate Toolbox project
Analysis of the Ultimate Toolbox projectAnalysis of the Ultimate Toolbox project
Analysis of the Ultimate Toolbox project
 
PVS-Studio vs Chromium
PVS-Studio vs ChromiumPVS-Studio vs Chromium
PVS-Studio vs Chromium
 
Intel IPP Samples for Windows - error correction
Intel IPP Samples for Windows - error correctionIntel IPP Samples for Windows - error correction
Intel IPP Samples for Windows - error correction
 
Optimization in the world of 64-bit errors
Optimization  in the world of 64-bit errorsOptimization  in the world of 64-bit errors
Optimization in the world of 64-bit errors
 
How VivaCore library appeared
How VivaCore library appearedHow VivaCore library appeared
How VivaCore library appeared
 
Debugging and optimization of multi-thread OpenMP-programs
Debugging and optimization of multi-thread OpenMP-programsDebugging and optimization of multi-thread OpenMP-programs
Debugging and optimization of multi-thread OpenMP-programs
 
Interview with Anatoliy Kuznetsov, the author of BitMagic C++ library
Interview with Anatoliy Kuznetsov, the author of BitMagic C++ libraryInterview with Anatoliy Kuznetsov, the author of BitMagic C++ library
Interview with Anatoliy Kuznetsov, the author of BitMagic C++ library
 
Changes in programmer tools' infrastructure
Changes in programmer tools' infrastructureChanges in programmer tools' infrastructure
Changes in programmer tools' infrastructure
 
Lesson 21. Pattern 13. Data alignment
Lesson 21. Pattern 13. Data alignmentLesson 21. Pattern 13. Data alignment
Lesson 21. Pattern 13. Data alignment
 
Regular use of static code analysis in team development
Regular use of static code analysis in team developmentRegular use of static code analysis in team development
Regular use of static code analysis in team development
 

Semelhante a Some examples of the 64-bit code errors

C++ Code as Seen by a Hypercritical Reviewer
C++ Code as Seen by a Hypercritical ReviewerC++ Code as Seen by a Hypercritical Reviewer
C++ Code as Seen by a Hypercritical ReviewerAndrey Karpov
 
A scrupulous code review - 15 bugs in C++ code
A scrupulous code review - 15 bugs in C++ codeA scrupulous code review - 15 bugs in C++ code
A scrupulous code review - 15 bugs in C++ codePVS-Studio LLC
 
Flashback, el primer malware masivo de sistemas Mac
Flashback, el primer malware masivo de sistemas MacFlashback, el primer malware masivo de sistemas Mac
Flashback, el primer malware masivo de sistemas MacESET Latinoamérica
 
Programming with GUTs
Programming with GUTsProgramming with GUTs
Programming with GUTsKevlin Henney
 
Look Ma, “update DB to HTML5 using C++”, no hands! 
Look Ma, “update DB to HTML5 using C++”, no hands! Look Ma, “update DB to HTML5 using C++”, no hands! 
Look Ma, “update DB to HTML5 using C++”, no hands! aleks-f
 
What We Talk About When We Talk About Unit Testing
What We Talk About When We Talk About Unit TestingWhat We Talk About When We Talk About Unit Testing
What We Talk About When We Talk About Unit TestingKevlin Henney
 
Checking the Source SDK Project
Checking the Source SDK ProjectChecking the Source SDK Project
Checking the Source SDK ProjectAndrey Karpov
 
Diego vega deber 29 03-11
Diego vega deber 29 03-11Diego vega deber 29 03-11
Diego vega deber 29 03-11diego
 
Lesson 17. Pattern 9. Mixed arithmetic
Lesson 17. Pattern 9. Mixed arithmeticLesson 17. Pattern 9. Mixed arithmetic
Lesson 17. Pattern 9. Mixed arithmeticPVS-Studio
 
Compiler design.pdf
Compiler design.pdfCompiler design.pdf
Compiler design.pdfNitesh Dubey
 
Go vs C++ - CppRussia 2019 Piter BoF
Go vs C++ - CppRussia 2019 Piter BoFGo vs C++ - CppRussia 2019 Piter BoF
Go vs C++ - CppRussia 2019 Piter BoFTimur Safin
 
Clean Code Development
Clean Code DevelopmentClean Code Development
Clean Code DevelopmentPeter Gfader
 
Mozilla とブラウザゲーム
Mozilla とブラウザゲームMozilla とブラウザゲーム
Mozilla とブラウザゲームNoritada Shimizu
 
Mouse programming in c
Mouse programming in cMouse programming in c
Mouse programming in cgkgaur1987
 
Lesson 9. Pattern 1. Magic numbers
Lesson 9. Pattern 1. Magic numbersLesson 9. Pattern 1. Magic numbers
Lesson 9. Pattern 1. Magic numbersPVS-Studio
 
Deep dumpster diving 2010
Deep dumpster diving 2010Deep dumpster diving 2010
Deep dumpster diving 2010RonnBlack
 
Самые вкусные баги из игрового кода: как ошибаются наши коллеги-программисты ...
Самые вкусные баги из игрового кода: как ошибаются наши коллеги-программисты ...Самые вкусные баги из игрового кода: как ошибаются наши коллеги-программисты ...
Самые вкусные баги из игрового кода: как ошибаются наши коллеги-программисты ...DevGAMM Conference
 
Getting started cpp full
Getting started cpp   fullGetting started cpp   full
Getting started cpp fullVõ Hòa
 

Semelhante a Some examples of the 64-bit code errors (20)

C++ Code as Seen by a Hypercritical Reviewer
C++ Code as Seen by a Hypercritical ReviewerC++ Code as Seen by a Hypercritical Reviewer
C++ Code as Seen by a Hypercritical Reviewer
 
Ac2
Ac2Ac2
Ac2
 
A scrupulous code review - 15 bugs in C++ code
A scrupulous code review - 15 bugs in C++ codeA scrupulous code review - 15 bugs in C++ code
A scrupulous code review - 15 bugs in C++ code
 
Flashback, el primer malware masivo de sistemas Mac
Flashback, el primer malware masivo de sistemas MacFlashback, el primer malware masivo de sistemas Mac
Flashback, el primer malware masivo de sistemas Mac
 
Programming with GUTs
Programming with GUTsProgramming with GUTs
Programming with GUTs
 
Look Ma, “update DB to HTML5 using C++”, no hands! 
Look Ma, “update DB to HTML5 using C++”, no hands! Look Ma, “update DB to HTML5 using C++”, no hands! 
Look Ma, “update DB to HTML5 using C++”, no hands! 
 
What We Talk About When We Talk About Unit Testing
What We Talk About When We Talk About Unit TestingWhat We Talk About When We Talk About Unit Testing
What We Talk About When We Talk About Unit Testing
 
Statistics.cpp
Statistics.cppStatistics.cpp
Statistics.cpp
 
Checking the Source SDK Project
Checking the Source SDK ProjectChecking the Source SDK Project
Checking the Source SDK Project
 
Diego vega deber 29 03-11
Diego vega deber 29 03-11Diego vega deber 29 03-11
Diego vega deber 29 03-11
 
Lesson 17. Pattern 9. Mixed arithmetic
Lesson 17. Pattern 9. Mixed arithmeticLesson 17. Pattern 9. Mixed arithmetic
Lesson 17. Pattern 9. Mixed arithmetic
 
Compiler design.pdf
Compiler design.pdfCompiler design.pdf
Compiler design.pdf
 
Go vs C++ - CppRussia 2019 Piter BoF
Go vs C++ - CppRussia 2019 Piter BoFGo vs C++ - CppRussia 2019 Piter BoF
Go vs C++ - CppRussia 2019 Piter BoF
 
Clean Code Development
Clean Code DevelopmentClean Code Development
Clean Code Development
 
Mozilla とブラウザゲーム
Mozilla とブラウザゲームMozilla とブラウザゲーム
Mozilla とブラウザゲーム
 
Mouse programming in c
Mouse programming in cMouse programming in c
Mouse programming in c
 
Lesson 9. Pattern 1. Magic numbers
Lesson 9. Pattern 1. Magic numbersLesson 9. Pattern 1. Magic numbers
Lesson 9. Pattern 1. Magic numbers
 
Deep dumpster diving 2010
Deep dumpster diving 2010Deep dumpster diving 2010
Deep dumpster diving 2010
 
Самые вкусные баги из игрового кода: как ошибаются наши коллеги-программисты ...
Самые вкусные баги из игрового кода: как ошибаются наши коллеги-программисты ...Самые вкусные баги из игрового кода: как ошибаются наши коллеги-программисты ...
Самые вкусные баги из игрового кода: как ошибаются наши коллеги-программисты ...
 
Getting started cpp full
Getting started cpp   fullGetting started cpp   full
Getting started cpp full
 

Último

FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhisoniya singh
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxOnBoard
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?XfilesPro
 

Último (20)

FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptx
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food Manufacturing
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?
 

Some examples of the 64-bit code errors

  • 1. Some examples of the 64-bit code errors Author: Evgeniy Ryzhkov Date: 23.07.2007 Abstract While porting 32-bit software to 64-bit systems there may appear some errors in the code of applications which were written in C++ language. The cause for these hides in the alteration of the base data types (to be more exact, in the relations between them) with the new hardware platform. This article contains various examples of 64-bit errors. However, we have learnt much more examples and types of errors since we started writing the article and they were not included into it. Please see the article "A Collection of Examples of 64-bit Errors in Real Programs" that covers defects in 64-bit programs we know of most thoroughly. We also recommend you to study the course "Lessons on development of 64-bit C/C++ applications" where we describe the methodology of creating correct 64- bit code and searching for all types of defects using the Viva64 code analyzer. Introduction While porting 32-bit software to 64-bit systems there may appear some errors in the code of applications which were written in C++ language. The cause for these hides in the alteration of the base data types (to be more exact, in the relations between them) with the new hardware platform. "But isn't C++ a high-level language!" you may ask, and you will be right. But still all the high-level abstractions are realized through the low-level data types. Help documentation for developers is sure to contain the description of such errors. However, even such authoritative sources as, for example MSDN, often give only platitudes, for instance: • int and long remained 32-bit ones with 64-bit versions of Widows; • size_t, time_t, and ptrdiff_t became 64-bit ones with 64-bit versions of Windows. But what does it mean for a developer and what problems may it potentially cause - all this is not reported in the help. Meanwhile, there are very few articles which contain certain examples of application code errors in 64- bit Windows versions. This article is to fill the vacuum. First of all some terminology. Memsize type is any data type which changes its size when the digit capacity of architecture is changed from 32 bits to 64 bits. The examples are size_t, ptrdiff_t, DWORD_PTR, LONG_PTR and others. Take a note that only short examples of errors are given in the article. The explanation of their causes are given in the article "20 issues of porting C++ of porting C++ code on the 64-bit platform" http://www.viva64.com/art-1-2-599168895.html .
  • 2. An error source code example Let us not harass the developers who wish to get down to studying the error examples, so let's show the whole source code of such a program. After the source code each error will be considered separately. To demonstrate the errors it is necessary to compile and run this code in the 64-bit mode. You can find the source code of an application which contains this code in a Viva64 distributive named PortSample. For this purpose download and install Viva64 (www.viva64.com/download.php) and then install PortSamle from program folder Viva64. bool IsX64Platform() { return sizeof(size_t) == 8; } template <typename A, typename B> inline size_t SafeMul(A a, B b) { return static_cast<size_t>(a) * static_cast<size_t>(b); } template <typename A, typename B, typename C> inline size_t SafeMul(A a, B b, C c) { return static_cast<size_t>(a) * static_cast<size_t>(b) * static_cast<size_t>(c); } template <typename A, typename B, typename C, typename D> inline size_t SafeMul(A a, B b, C c, D d) { return static_cast<size_t>(a) * static_cast<size_t>(b) * static_cast<size_t>(c) * static_cast<size_t>(d); } void V101() { unsigned imageWidth = 1000; unsigned imageHeght = 1000; unsigned bytePerPixel = 3; unsigned maxFrameCountInBuffer; if (IsX64Platform()) {
  • 3. maxFrameCountInBuffer = 2000; } else { maxFrameCountInBuffer = 100; } size_t bufferSize = imageWidth * imageHeght * bytePerPixel * maxFrameCountInBuffer; BYTE *buffer = static_cast<BYTE *>(malloc(bufferSize)); BYTE *ptr = buffer; for (unsigned frame = 0; frame != maxFrameCountInBuffer; ++frame) for (unsigned width = 0; width != imageWidth; ++width) for (unsigned height = 0; height != imageHeght; ++height) { *ptr++ = 0xFF; *ptr++ = 0xFF; *ptr++ = 0x00; } free (buffer); } void V102() { int domainWidth; int domainHeght; int domainDepth; if (IsX64Platform()) { domainWidth = 2000; domainHeght = 2000; domainDepth = 2000; } else { domainWidth = 500; domainHeght = 500; domainDepth = 500;
  • 4. } char *buffer = new char [size_t(domainWidth) * size_t(domainHeght) * size_t(domainDepth)]; char *current = buffer; char *end = buffer; end += domainWidth * domainHeght * domainDepth; while (current != end) *current++ = 1; delete [] buffer; } void V103() { size_t Megabyte = 1048576; size_t Gigabyte = 1073741824; size_t n = IsX64Platform() ? Gigabyte : Megabyte; unsigned arraySize = n * sizeof(INT_PTR); INT_PTR *buffer = (INT_PTR *)malloc(size_t(arraySize)); for (size_t i = 0; i != n; ++i) buffer[i] = 0; free(buffer); } void V104() { volatile size_t n; if (IsX64Platform()) { n = SafeMul(5, 1024, 1024, 1024); } else {
  • 5. n = SafeMul(5, 1024, 1024); } char *buffer = new char [n]; volatile size_t index = 0; volatile unsigned i; for (i = 0; i != n; ++i) buffer[index++] = 1; delete [] buffer; } void V105() { bool flag = true; unsigned a = unsigned(-1); if ((flag ? a : sizeof(float)) != size_t(-1)) { throw CString("x64 portability issues"); } } void V106() { void *buffer; const unsigned Megabyte = 1024 * 1024; const unsigned Gigabyte = 1024 * 1024 * 1024; unsigned unit; if (IsX64Platform()) unit = Gigabyte; else unit = Megabyte; buffer = malloc(5 * unit);
  • 6. if (IsX64Platform()) memset(buffer, 0, SafeMul(5, 1024, 1024, 1024)); else memset(buffer, 0, SafeMul(5, 1024, 1024)); free(buffer); } void V107_FillFunction(char *array, unsigned arraySize) { for (unsigned i = 0; i != arraySize; ++i) array[i] = 1; } void V107() { size_t n; if (IsX64Platform()) { n = SafeMul(5, 1024, 1024, 1024); } else { n = SafeMul(5, 1024, 1024); } char *array = (char *)malloc(n * sizeof(char)); memset(array, 0, n * sizeof(char)); V107_FillFunction(array, n); for (size_t i = 0; i != n; ++i) if (array[i] != 1) throw CString("x64 portability issues"); free(array); } void V108() { size_t n; if (IsX64Platform()) {
  • 7. n = SafeMul(5, 1024, 1024, 1024); } else { n = SafeMul(5, 1024, 1024); } char *array = (char *)malloc(n * sizeof(char)); memset(array, 0, n * sizeof(char)); volatile int index = 0; for (size_t i = 0; i != n; ++i) { array[index++] = 1; if (array[i] != 1) throw CString("x64 portability issues"); } free(array); } ptrdiff_t UnsafeCalcIndex(int x, int y, int width) { volatile int result = x + y * width; return result; } void V109() { int domainWidth; int domainHeght; if (IsX64Platform()) { domainWidth = 50000; domainHeght = 50000; } else { domainWidth = 5000; domainHeght = 5000; } char *array = (char *)malloc(SafeMul(domainWidth, domainHeght));
  • 8. for (int x = 0; x != domainWidth; ++x) for (int y = 0; y != domainHeght; ++y) { array[UnsafeCalcIndex(x, y, domainWidth)] = 55; } free(array); } int UnsafeStrLen(const char *text) { const char *ptr = text; while (*ptr != 0) ++ptr; return ptr - text; } void V110() { size_t n; CString trueSize; if (IsX64Platform()) { n = SafeMul(3, 1024, 1024, 1024); trueSize = _T("3221225472"); } else { n = SafeMul(3, 1024, 1024); trueSize = _T("3145728"); } char *str = (char *)malloc(n * sizeof(char)); memset(str, 'V', n * sizeof(char)); str[n - 1] = 0; int len = UnsafeStrLen(str); CString falseSize; falseSize.Format(_T("%i"), len + 1); free(str);
  • 9. if (falseSize != trueSize) throw CString(_T("x64 portability issues")); } void V111() { char invalidStr[100], validStr[100]; const char *invalidFormat = "%u"; const char *validFormat = "%Iu"; size_t a = SIZE_MAX; sprintf_s(invalidStr, sizeof(invalidStr),invalidFormat, a); sprintf_s(validStr, sizeof(validStr), validFormat, a); if (strcmp(invalidStr, validStr) != 0) throw CString(_T("x64 portability issues")); } void V113() { size_t a = size_t(-1); double b = a; --a; --b; size_t c = b; if (a != c) throw CString(_T("x64 portability issues")); } void V114() { unsigned intPtr[10] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }; size_t *sizetPtr = (size_t *)(intPtr); size_t sum = 0; for (size_t i = 0; i != 10; ++i)
  • 10. sum += sizetPtr[i]; if (sum != 45) throw CString(_T("x64 portability issues")); } void V301() { class CWinAppTest { public: virtual void WinHelp(DWORD_PTR, UINT) { ::AfxMessageBox(_T("Cannot activate WinHelp")); } }; class CPortSampleApp : public CWinAppTest { public: virtual void WinHelp(DWORD, UINT) { ::AfxMessageBox(_T("WinHelp activated")); } }; CWinAppTest *Application = new CPortSampleApp(); Application->WinHelp(NULL, 0); delete Application; } int _tmain(int argc, TCHAR* argv[]) { V101(); V102(); V103(); V104(); V105(); V106();
  • 11. V107(); V108(); V109(); V110(); V111(); V112(); V113(); V114(); V201(); V202(); V203(); V301(); return 0; } Now, when we see the whole code, let's consider the functions which contain errors. When we say that a function contains an error we mean the following: the given code is able to compile and function in the 32-bit regime, but after compiling for the64-bit regime its functioning becomes incorrect up to fall. Implicit conversion to memsize type void V101() { unsigned imageWidth = 1000; unsigned imageHeght = 1000; unsigned bytePerPixel = 3; unsigned maxFrameCountInBuffer; if (IsX64Platform()) { maxFrameCountInBuffer = 2000; } else { maxFrameCountInBuffer = 100; } size_t bufferSize = imageWidth * imageHeght *
  • 12. bytePerPixel * maxFrameCountInBuffer; BYTE *buffer = static_cast<BYTE *>(malloc(bufferSize)); BYTE *ptr = buffer; for (unsigned frame = 0; frame != maxFrameCountInBuffer; ++frame) for (unsigned width = 0; width != imageWidth; ++width) for (unsigned height = 0; height != imageHeght; ++height) { *ptr++ = 0xFF; *ptr++ = 0xFF; *ptr++ = 0x00; } free (buffer); } The problem is in the next line: size_t bufferSize = imageWidth * imageHeght * bytePerPixel * maxFrameCountInBuffer; All the varibles in the multiplation are of unsigned type, which in both 32-bit and 64-bit regimes pssesses the sie of 32 bits. But the result of multiplation is written with a variable of size_t type which in the 32-bit mode possesses the size coinciding with the size of unsigned type and they don't coincide in the 64-bit mode. But the compiler fulfills the extention of the result type up to unsigned one.It seems that there is no problem at all. But the problem exists! If the result of multplication exceeds 4 gigabytes the overflow will occur and the result will be incorrect. The use of non-memsize types for the pointers arithmetic void V102() { int domainWidth; int domainHeght; int domainDepth; if (IsX64Platform()) { domainWidth = 2000; domainHeght = 2000; domainDepth = 2000;
  • 13. } else { domainWidth = 500; domainHeght = 500; domainDepth = 500; } char *buffer = new char [size_t(domainWidth) * size_t(domainHeght) * size_t(domainDepth)]; char *current = buffer; char *end = buffer; end += domainWidth * domainHeght * domainDepth; while (current != end) *current++ = 1; delete [] buffer; } The problem in the given code is the pointers arithmetic, to be more exact, the use of non-memsize types for this arithmetic: end += domainWidth * domainHeght * domainDepth; The error is that with the 64-bit platform the pointer end will never have the increment larger than 4 gigabytes. Implicit conversion of memsize type void V103() { size_t Megabyte = 1048576; size_t Gigabyte = 1073741824; size_t n = IsX64Platform() ? Gigabyte : Megabyte; unsigned arraySize = n * sizeof(INT_PTR); INT_PTR *buffer = (INT_PTR *)malloc(size_t(arraySize)); for (size_t i = 0; i != n; ++i)
  • 14. buffer[i] = 0; free(buffer); } There is an obvious error in the following code fragment. unsigned arraySize = n * sizeof(INT_PTR); It's the implicit conversion to the unsigned type of a variable of larger capacity (on a 64-bit platform). Implicit conversion to memsize type in an arithmetic sentence void V104() { volatile size_t n; if (IsX64Platform()) { n = SafeMul(5, 1024, 1024, 1024); } else { n = SafeMul(5, 1024, 1024); } char *buffer = new char [n]; volatile size_t index = 0; volatile unsigned i; for (i = 0; i != n; ++i) buffer[index++] = 1; delete [] buffer; } It's strange but operations of comparing two variables may be also the source of trouble. In the following line for (i = 0; i != n; ++i) the problem is that the variable i of unsigned type is compared to the variable n of size_t type, and after that this variable extends. But as unsigned never exceeds 4 gigabytes , than i will never be larger than this value. What do we have as a result? We have an infinite loop! as the conditions of i != n will always be fulfilled.
  • 15. Implicit conversion to memsize type in ?: operation void V105() { bool flag = true; unsigned a = unsigned(-1); if ((flag ? a : sizeof(float)) != size_t(-1)) { throw CString("x64 portability issues"); } } This example is very much alike to the previous one, the problem can be found in the following line: if ((flag ? a : sizeof(float)) != size_t(-1)) { here the variable a is of unsigned type which may give an incorrect result when compared to size_t. Why? Just because unsigned(-1) is not equal to size_t (-1). Implicit conversion of a function argument to memsize type void V106() { void *buffer; const unsigned Megabyte = 1024 * 1024; const unsigned Gigabyte = 1024 * 1024 * 1024; unsigned unit; if (IsX64Platform()) unit = Gigabyte; else unit = Megabyte; buffer = malloc(5 * unit); if (IsX64Platform()) memset(buffer, 0, SafeMul(5, 1024, 1024, 1024)); else memset(buffer, 0, SafeMul(5, 1024, 1024)); free(buffer);
  • 16. } In the line buffer = malloc(5 * unit); the developer hoped to get a 5-gigabyte buffer with a 64-bit system. But an error will occur here. You ask why? Just because the malloc() function possesses an argument of memsize type and 5 is quite an appropriate value. But when (5 * unit) is multiplied an overflow will occur because the unit variable is of unsigned type. The result will for sure be not 5 gigabytes. Implicit conversion of a function argument of memsize type to the 32-bit type void V107_FillFunction(char *array, unsigned arraySize) { for (unsigned i = 0; i != arraySize; ++i) array[i] = 1; } void V107() { size_t n; if (IsX64Platform()) { n = SafeMul(5, 1024, 1024, 1024); } else { n = SafeMul(5, 1024, 1024); } char *array = (char *)malloc(n * sizeof(char)); memset(array, 0, n * sizeof(char)); V107_FillFunction(array, n); for (size_t i = 0; i != n; ++i) if (array[i] != 1) throw CString("x64 portability issues"); free(array); } In the line with function call V107_FillFunction(array, n);
  • 17. there occurs the conversion of type of the variable n to unsigned. This means truncation of the variable value, the result of this is that not the whole array is filled. The use of incorrect types for indexation void V108() { size_t n; if (IsX64Platform()) { n = SafeMul(5, 1024, 1024, 1024); } else { n = SafeMul(5, 1024, 1024); } char *array = (char *)malloc(n * sizeof(char)); memset(array, 0, n * sizeof(char)); volatile int index = 0; for (size_t i = 0; i != n; ++i) { array[index++] = 1; if (array[i] != 1) throw CString("x64 portability issues"); } free(array); } If not a memsize type is used for array indexation, it is possible that there will occur an error like the following: array[index++] = 1; The problem is the following: in case if there are more than 4 gigabytes of elements , you may not use the variable of unsigned type. Conversion to memsize type using a return value ptrdiff_t UnsafeCalcIndex(int x, int y, int width) { volatile int result = x + y * width; return result;
  • 18. } void V109() { int domainWidth; int domainHeght; if (IsX64Platform()) { domainWidth = 50000; domainHeght = 50000; } else { domainWidth = 5000; domainHeght = 5000; } char *array = (char *)malloc(SafeMul(domainWidth, domainHeght)); for (int x = 0; x != domainWidth; ++x) for (int y = 0; y != domainHeght; ++y) { array[UnsafeCalcIndex(x, y, domainWidth)] = 55; } free(array); } It's amazing, but in this example the error is in the line: return result; The value result is of int type which will be implicitly expanded to ptrdiff_t. But the function UnsafeCalcIndex() will never be able to return the index of the element following 2 gigabytes. It would be more correct to say that the error is the wrongly chosen type of the variable result. In this case this variable must be of UnsafeCalcIndex() type. Conversion of memsize type using a return value int UnsafeStrLen(const char *text) { const char *ptr = text; while (*ptr != 0) ++ptr; return ptr - text;
  • 19. } void V110() { size_t n; CString trueSize; if (IsX64Platform()) { n = SafeMul(3, 1024, 1024, 1024); trueSize = _T("3221225472"); } else { n = SafeMul(3, 1024, 1024); trueSize = _T("3145728"); } char *str = (char *)malloc(n * sizeof(char)); memset(str, 'V', n * sizeof(char)); str[n - 1] = 0; int len = UnsafeStrLen(str); CString falseSize; falseSize.Format(_T("%i"), len + 1); if (falseSize != trueSize) throw CString(_T("x64 portability issues")); } The situation is the same as in the previous example and the error is again in the line of the return value: return ptr - text; The difference is that here we deal with the conversion of memsize type to int type. The result is that the buffer size (from the example) will never be figured out if it is larger than 2 gigabytes. Call of function with variable number of arguments with memsize parameter void V111() { char invalidStr[100], validStr[100];
  • 20. const char *invalidFormat = "%u"; const char *validFormat = "%Iu"; size_t a = SIZE_MAX; sprintf_s(invalidStr, sizeof(invalidStr),invalidFormat, a); sprintf_s(validStr, sizeof(validStr), validFormat, a); if (strcmp(invalidStr, validStr) != 0) throw CString(_T("x64 portability issues")); } Functions with variable number of arguments are often used for formatting and input/output of text lines. Incorrect presetting of the format line may cause incorrect work. const char *invalidFormat = "%u"; sprintf_s(invalidStr, sizeof(invalidStr),invalidFormat, a); The format line in this example is estimated for 32-bit mode of working and in 64-bit mode it will cause incorrect output. Implicit conversion of memsize type to double and vice versa void V113() { size_t a = size_t(-1); double b = a; --a; --b; size_t c = b; if (a != c) throw CString(_T("x64 portability issues")); } In this example there are errors in two lines: double b = a; and size_t c = b; Such asignment with 64-bit systems is incorrect because it may cause loss of preision.
  • 21. Explicit type conversion if the course of work with pointers void V114() { unsigned intPtr[10] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }; size_t *sizetPtr = (size_t *)(intPtr); size_t sum = 0; for (size_t i = 0; i != 10; ++i) sum += sizetPtr[i]; if (sum != 45) throw CString(_T("x64 portability issues")); } C++ being a low-level language allows working with memory at the pointer level. Explicit type conversion using pointers is anyway dangerous, but conversion of memsize types , as shown in the example, is twice dangerous. size_t *sizetPtr = (size_t *)(intPtr); The matter is the difference of types size_t and unsigned. Overriding virtual functions void V301() { class CWinAppTest { public: virtual void WinHelp(DWORD_PTR, UINT) { ::AfxMessageBox(_T("Cannot activate WinHelp")); } }; class CPortSampleApp : public CWinAppTest { public: virtual void WinHelp(DWORD, UINT) { ::AfxMessageBox(_T("WinHelp activated")); }
  • 22. }; CWinAppTest *Application = new CPortSampleApp(); Application->WinHelp(NULL, 0); delete Application; } One of the funniest errors of C++ applications which can appear with 64-bit systems is related to virtual functions. Pay your attention to the parameters of virtual functions in the example above. With a 32-bit system DWORD_PTR and DWORD coincide and there appears an overridden virtual function, and with a 64-bit platform there are two different functions! As a result the call of WinHelp() function from the example will cause the appearance of "Cannot activate WinHelp" message. Pro conclusion Thus, we have listed all the main code errors which appear when a code is ported to 64-bit systems. You might think many of them are sophisticated. For example, who, for God's sake, may need a 5 gigabyte buffer at Windows system? Maybe this problem is not very acute in 2007, though many resource- intensive applications are already able to use such amount of memory. We'll see if this article will be actual in a couple of years. Maybe just you will debug an error which appears when several gigabytes of memory are allocated. Some information about the author Evgeniy Ryzhkov is one of the developers of the static code analyzer Viva64 which is meant for simplifying the migration of applications to 64-bit platforms. He studies the migration of 32-bit program systems to 64-bit platforms.