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"

Man this is fun. Not sure I thanked Elena enough for this feature. It's going to be a killer :).

:D

On Fri, Mar 26, 2010 at 5:32 AM, Alena Laskavaia <elaskavaia.cdt@xxxxxxxxx> wrote:
I am not good at C++. I misunderstood the request. Just re-open it I reverse the checker :)

Elmenthaler, Jens wrote:

Ouch, my intention when proposing this checker (https://bugs.eclipse.org/bugs/show_bug.cgi?id=281187) was exactly to make sure that no-one declares the exception parameter other than by reference, as Doug and Andrew already pointed out. This is really frequent mistake I see in code reviews I conduct. Looks like an unfortunate misunderstanding.

 

Shall I enter a new CR?

 

Jens.

 


From: cdt-dev-bounces@xxxxxxxxxxx [mailto:cdt-dev-bounces@xxxxxxxxxxx] On Behalf Of Doug Schaefer
Sent: Freitag, 26. März 2010 06:55
To: CDT General developers list.
Subject: 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

 


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

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



Back to the top