libstdc++/10093: Regression: Setting failbit in exceptions doesn't work
jlquinn@optonline.net
jlquinn@optonline.net
Mon Mar 24 07:14:00 GMT 2003
Martin Sebor writes:
> The following reply was made to PR libstdc++/10093; it has been noted by GNATS.
>
> From: Martin Sebor <sebor@roguewave.com>
> To: gcc-gnats@gcc.gnu.org
> Cc:
> Subject: Re: libstdc++/10093: Regression: Setting failbit in exceptions doesn't
> work
> Date: Sun, 23 Mar 2003 13:18:57 -0700
>
> Pétur Runólfsson wrote:
> ...
> >
> > Note the "during input". I read that as meaning that this refers only
> > to exceptions thrown by the call to num_get::get(), not to exceptions
> > thrown from other functions the extractors may call.
>
> The general requirements on what causes exceptions to be caught
> and rethrown are buried in 27.6.1.1, p1-4. According to the text
> only calls to members of streambuf are supposed to be checked
> for exceptions. But because it's not possible to distinguish
> between an exception thrown by, say, a (virtual) member function
> of ctype called from num_get::get() and one thrown by a (virtual)
> streambuf member called (indirectly, via an istreambuf_iterator
> member) from num_get::get(), the requirement cannot realistically
> be taken to mean just exceptions thrown during a call to num_get
> ::get() and not, for instance, ctype::is() called by the istream
> ::sentry ctor. IMO, stream members should consistently catch all
> exceptions from any functions they may call.
I buy this :-) Given that we catch all the exceptions, when do we
rethrow? The original text says rethrow if badbit is set in the
exception mask. DR64 says to rethrow if failbit is set and the
exception mask has failbit set. So, does it make sense to change
catch(exception& __fail)
{
// 27.6.1.2.1 Common requirements.
// Turn this on without causing an ios::failure to be thrown.
this->_M_setstate(ios_base::badbit);
if ((this->exceptions() & ios_base::badbit) != 0)
__throw_exception_again;
}
to
catch(exception& __fail)
{
// 27.6.1.2.1 Common requirements.
// Turn this on without causing an ios::failure to be thrown.
this->_M_setstate(ios_base::badbit);
if ((this->exceptions() & (ios_base::badbit | ios_base::failbit))
__throw_exception_again;
}
?
Jerry Quinn
More information about the Libstdc++
mailing list