[RFC] basic_string: really weird try/catch blocks
Nathan Myers
ncm-nospam@cantrip.org
Mon Jan 19 04:25:00 GMT 2004
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
More information about the Libstdc++
mailing list