Flutterby™! : C++ exception specifications

Next unread comment / Catchup all unread comments User Account Info | Logout | XML/Pilot/etc versions | Long version (with comments) | Weblog archives | Site Map | | Browse Topics

C++ exception specifications

2007-05-17 03:09:22.181206+00 by Dan Lyke 2 comments

I knew that I'd seen the reason for C++ member functions of the form bool abc() const throw() before, but couldn't remember the details. It turns out there are good reasons I wasn't immediately familiar with them: A Pragmatic Look at Exception Specifications:

Moral #1: Never write an exception specification.

Moral #2: Except possibly an empty one, but if I were you I’d avoid even that.

[ related topics: C++ ]

comments in ascending chronological order (reverse):

#Comment Re: made: 2007-05-17 13:11:17.134134+00 by: markd

and also avoid throwing exceptions across linkable entities. I had a fun time tracking down a behavior change between two gcc versions when an exception was thrown from one loadable .so to another one.

#Comment Re: made: 2007-05-17 13:18:37.084278+00 by: other_todd

Good article, and I don't even work in C++ except at gunpoint.