
On 7/6/06, Kevin Spinar <spinarkm@gmail.com> wrote:
On 7/6/06, Emil Dotchevski <emildotchevski@hotmail.com> 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