Issue 125105 - Throw C++ exceptions by value
Summary: Throw C++ exceptions by value
Alias: None
Product: General
Classification: Code
Component: help (show other issues)
Version: 3.3.0 or older (OOo)
Hardware: All All
: P3 Major (vote)
Target Milestone: ---
Assignee: AOO issues mailing list
QA Contact:
Depends on: 122768
Blocks: 122766
  Show dependency tree
Reported: 2014-06-16 12:59 UTC by
Modified: 2014-06-16 14:38 UTC (History)
0 users

See Also:
Latest Confirmation in: ---
Developer Difficulty: ---


Note You need to log in before you can comment on or make changes to this issue.
Description 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 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".