V116. Memsize type is used for catch.

The analyzer found a possible error related to the use of memsize type for catching exception. The error may consist in the incorrect exception handling.

Let's examine an example of the code which contains 'throw' and 'catch' operators.

try {
    try {
      throw UINT64(-1);
    catch(size_t) {
      cout << "x64 portability issues" << endl;
  catch(UINT64) {
      cout << "OK" << endl;

The work result on the 32-bit system: OKThe work result on the 64-bit system: x64 portability issues

This behavior change is connected with what on 64-bit system the 'size_t' type is equivalent to 'UINT64'.

Correction of the described situation consists in change of a code for achievement of necessary logic of work.

More right correction will consist in refusal of similar practice of programming. We recommend using special classes for sending information about the error.

Additional materials on this topic:

  • 64-bit Lessons. Lesson 20. Pattern 12. Exceptions.

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 →