Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [cdt-dev] Codan warning "Catch uses reference to exception"

When I did use exceptions in a previous life, I did catch by reference. I'm not sure how exceptions get implemented, but it seemed catching by value was a bad idea since it would theoretically mean always calling the copy constructor on the catch, which could lead to more problems.

On Thu, Mar 25, 2010 at 9:10 PM, Andrew Gvozdev <angvoz.dev@xxxxxxxxx> wrote:
Elena,
Why do you want us to avoid catching exceptions by reference? Shouldn't it be the other way around? Catching by reference is recommended by C++ experts, for example Herb Sutter/Andrei Alexandresscu "C++ Coding Standards", Rule 73 "Throw by value, catch by reference". For one thing, this avoids copying and potentially slicing the exception.
 
Andrew

_______________________________________________
cdt-dev mailing list
cdt-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/cdt-dev



Back to the top