Issue 125105

Summary: Throw C++ exceptions by value
Product: General Reporter: hdu <hdu>
Component: helpAssignee: AOO issues mailing list <issues>
Status: CONFIRMED --- QA Contact:
Severity: Major    
Priority: P3    
Version: 3.3.0 or older (OOo)   
Target Milestone: ---   
Hardware: All   
OS: All   
Issue Type: ENHANCEMENT Latest Confirmation in: ---
Developer Difficulty: ---
Issue Depends on: 122768    
Issue Blocks: 122766    

Description hdu@apache.org 2014-06-16 12:59:28 UTC
Best practices for C++ suggest to catch exceptions by value. The related issue to catch exceptions by a const reference has already been addressed in issue 122768.

The AOO code base contains a lot of instances where exception objects are thrown with code patterns like
   throw new RuntimeException()
where the surrounding and catching code doesn't seem to handle that a pointer is being thrown instead of an exception. So the exception might not be caught. If the (now deprecated) throw lists come into play and if they specify the exception itself but not the pointer then this can cause pseudo-crashes because C++ requires that terminate() is being called.

So the existing code with "throw new X()" should be changed to "throw X()" and the related throw-lists and catch clauses should be checked.
Comment 1 hdu@apache.org 2014-06-16 14:38:21 UTC
As the title suggest the first sentence above should of course be: "Best practices for C++ suggest to throw exceptions by value".