Boost logo

Boost :

From: Gregory Dai (gregory.dai_at_[hidden])
Date: 2006-07-08 19:59:19


On 7/6/06, Kevin Spinar <spinarkm_at_[hidden]> wrote:
>
> 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.

I've got a related question: Assume a multithreaded C++ program, if one
thread is handling an exception while another thread starts to throw one,
what would happen? terminate() will be called?

Let's assume each thread has its own try/catch structure in its upper-most
main routine.

The reason I asked the question: Recently we moved from g++ 2.96 to 4.1. I
started to notice terminate() gets called much more frequently with the new
compiler than with the old one. I had the impression that the
exception-related code in the gcc library for 2.96 was more like a kludge,
so the new compiler may have come with a library more comforming to the C++
standard. However, this is for me practically a step backward.

Thanks,

Greg

Kevin Spinar
> _______________________________________________
> Unsubscribe & other changes:
> http://lists.boost.org/mailman/listinfo.cgi/boost
>


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