Boost logo

Boost :

From: Kevin Spinar (spinarkm_at_[hidden])
Date: 2006-07-06 23:42:50


On 7/6/06, Kevin Spinar <spinarkm_at_[hidden]> wrote:
>
> On 7/6/06, Emil Dotchevski <emildotchevski_at_[hidden]> wrote:
> >
> > Oleg Abrosimov wrote:
> >
> > > It can be rewritten as follows:
> > >
> > > if( count!=fread(buffer,size,count,stream.get()) ||
> > > ferror(stream.get()) ) boost::throw_<fread_error>() <<
> > > boost::wrap_string<tag_function>("fread") <<
> > > boost::wrap_errno() <<
> > > boost::weak_ptr<FILE>(stream);
> > > }
> >
> > Yes, but what happens if boost::wrap_string throws?
> >
>
> Similarily:
>
> throw std::runtime_error("my error");
>
> What happens if std::runtime_error's constructor throws? (a temporary
> std::string is created so the dynamic allocation could cause std::bad_alloc
> to be thrown)
>
> Apparently people consider this a non-issue. And so, it seems the fact
> that boost::wrap_string could throw is also a non-issue.
>

I'm sorry, i completely missed your point. If boost::wrap_string throws,
then the stack unwinds and when the boost::throw_ object gets destroyed,
it'll also throw, and std::terminate will be called because an exception was
thrown while another exception was already being handled. Yes, that's a
good point.

Kevin Spinar


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk