This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [RFC] basic_string: really weird try/catch blocks


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]