This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
Re: [RFC] basic_string: really weird try/catch blocks
- From: Nathan Myers <ncm-nospam at cantrip dot org>
- To: libstdc++ <libstdc++ at gcc dot gnu dot org>
- Date: Sun, 18 Jan 2004 20:24:59 -0800
- Subject: Re: [RFC] basic_string: really weird try/catch blocks
- References: <400AE71B.80706@suse.de>
On Sun, Jan 18, 2004 at 09:05:47PM +0100, Paolo Carlini wrote:
> in two _S_construct we have:
>
> try
> { _S_copy_chars(__r->_M_refdata(), __beg, __end); }
> catch(...)
> {
> __r->_M_destroy(__a);
> __throw_exception_again;
> }
I think this one has to stay. _S_copy_chars uses various operators
on __beg, which may throw, in general. Probably we need some test
cases with tetchy iteratators, to make sure the right thing happens
when they go off.
> try
> {
> if (__n)
> traits_type::assign(__r->_M_refdata(), __n, __c);
> }
> catch(...)
> {
> __r->_M_destroy(__a);
> __throw_exception_again;
> }
>
> respectively, which I cannot understand: we are basically
> talking about 'memcpy'/'memset' that definitely cannot throw.
>
> And, in 21.1.1: "Operations on Traits shall not throw exceptions."
The second case looks more like redundancy, probably copied from the
other code and not pruned sufficiently.
Nathan Myers
ncm-nospam@cantrip.org