V116. Memsize type is used for catch.
This rule belongs to the "Diagnosis of 64-bit errors" group. The rules in this group are no longer developed and may be disabled in the future. If you use these rules, please contact our support team—we will help you find a replacement or suggest an alternative solution.
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: OK
The 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.