Next: High Integrity CPP Guideline 9.4  Up: 9 Exceptions  Previous: High Integrity CPP Rule 9.2  Contents

High Integrity CPP Rule 9.3   Catch exceptions by reference.
(QA C++  4031)

Justification

Using pass-by-pointer for exceptions requires extra calls for memory allocation and deletion which may themselves cause further exceptions or memory loss if the exception object is not deleted. If an exception object is caught by value, information in a derived class may be sliced from the exception in this exception handler.

See also

Rule 11.4

Reference

More Effective C++ Item 13;Industrial Strength C++ 12.13;


HICPP VERSION 2.4  http://www.codingstandard.com   Copyright: © 2007 THE PROGRAMMING RESEARCH GROUP