This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
Re: throw specs on Standard destructors
Nathan Myers <ncm-nospam@cantrip.org> writes:
| On Wed, Dec 11, 2002 at 11:20:50AM -0600, Benjamin Kosnik wrote:
| > On Wed, 11 Dec 2002 08:34:27 -0800
| > Nathan Myers <ncm-nospam@cantrip.org> wrote:
| >
| > >No. An implementation is not required to declare destructors throw().
| > >Any code that fails if they're not so declared is broken, because it
| > >assumes an implementation detail that the standard doesn't specify.
| >
| > Sadly, agreed.
| >
| > However, this code does compile with 2.95/2.96 (but not with 3.x series
| > compilers). Adding the string and auto_ptr bits, conditionally so that
| > -pedantic will remove them, seems to be the solution.
|
| We still need to be careful not to generate a test and call
| to terminate(). Maybe a function try block with empty catch
| clause would suffice:
|
| basic_string::~basic_string()
| #ifndef __PEDANTIC__ // (or whatever it's called)
| throw()
| try
| #endif
| { _M_rep()->_M_dispose(this->get_allocator()); }
| #ifndef __PEDANTIC__
| catch(...) {} // discard embarrassments
| #endif
I'm unconfortable with the idea that GCC in default mode would accept
a broken code. But I understand that feeling isn't unanimously hold.
Still, the idea of spreagling the code with CPP hackery just to
support some broken code isn't appealing to me.
-- Gaby