This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug libstdc++/10093] [3.3/3.4 Regression] [L DR 61] Setting failbit in exceptions doesn't work
- From: "bkoz at gcc dot gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 24 Oct 2003 07:41:57 -0000
- Subject: [Bug libstdc++/10093] [3.3/3.4 Regression] [L DR 61] Setting failbit in exceptions doesn't work
- References: <20030315103601.10093.peturr02@ru.is>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=10093
------- Additional Comments From bkoz at gcc dot gnu dot org 2003-10-24 07:41 -------
I think something like this will work, but will have to be propagated throughout
the istream/ostream functions.
Index: include/bits/istream.tcc
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/include/bits/istream.tcc,v
retrieving revision 1.52
diff -c -p -r1.52 istream.tcc
*** include/bits/istream.tcc 12 Oct 2003 10:12:08 -0000 1.52
--- include/bits/istream.tcc 24 Oct 2003 07:39:25 -0000
*************** namespace std
*** 60,69 ****
while (!traits_type::eq_int_type(__c, __eof)
&& __ct.is(ctype_base::space,
traits_type::to_char_type(__c)))
! __c = __sb->snextc();
// _GLIBCXX_RESOLVE_LIB_DEFECTS
! // 195. Should basic_istream::sentry's constructor ever set eofbit?
if (traits_type::eq_int_type(__c, __eof))
__in.setstate(ios_base::eofbit);
}
--- 60,70 ----
while (!traits_type::eq_int_type(__c, __eof)
&& __ct.is(ctype_base::space,
traits_type::to_char_type(__c)))
! __c = __sb->snextc();
// _GLIBCXX_RESOLVE_LIB_DEFECTS
! // 195. Should basic_istream::sentry's constructor ever
! // set eofbit?
if (traits_type::eq_int_type(__c, __eof))
__in.setstate(ios_base::eofbit);
}
*************** namespace std
*** 113,124 ****
sentry __cerb(*this, false);
if (__cerb)
{
try
{
- ios_base::iostate __err = ios_base::iostate(ios_base::goodbit);
const __num_get_type& __ng = __check_facet(this->_M_num_get);
__ng.get(*this, 0, *this, __err, __n);
- this->setstate(__err);
}
catch(...)
{
--- 114,124 ----
sentry __cerb(*this, false);
if (__cerb)
{
+ ios_base::iostate __err = ios_base::iostate(ios_base::goodbit);
try
{
const __num_get_type& __ng = __check_facet(this->_M_num_get);
__ng.get(*this, 0, *this, __err, __n);
}
catch(...)
{
*************** namespace std
*** 128,133 ****
--- 128,134 ----
if ((this->exceptions() & ios_base::badbit) != 0)
__throw_exception_again;
}
+ this->setstate(__err);
}
return *this;
}
*************** namespace std
*** 140,149 ****
sentry __cerb(*this, false);
if (__cerb)
{
try
{
long __l;
- ios_base::iostate __err = ios_base::iostate(ios_base::goodbit);
const __num_get_type& __ng = __check_facet(this->_M_num_get);
__ng.get(*this, 0, *this, __err, __l);
// _GLIBCXX_RESOLVE_LIB_DEFECTS
--- 141,150 ----
sentry __cerb(*this, false);
if (__cerb)
{
+ ios_base::iostate __err = ios_base::iostate(ios_base::goodbit);
try
{
long __l;
const __num_get_type& __ng = __check_facet(this->_M_num_get);
__ng.get(*this, 0, *this, __err, __l);
// _GLIBCXX_RESOLVE_LIB_DEFECTS
*************** namespace std
*** 154,160 ****
__n = __l;
else
__err |= ios_base::failbit;
- this->setstate(__err);
}
catch(...)
{
--- 155,160 ----
*************** namespace std
*** 164,169 ****
--- 164,170 ----
if ((this->exceptions() & ios_base::badbit) != 0)
__throw_exception_again;
}
+ this->setstate(__err);
}
return *this;
}
*************** namespace std
*** 176,187 ****
sentry __cerb(*this, false);
if (__cerb)
{
try
{
- ios_base::iostate __err = ios_base::iostate(ios_base::goodbit);
const __num_get_type& __ng = __check_facet(this->_M_num_get);
__ng.get(*this, 0, *this, __err, __n);
- this->setstate(__err);
}
catch(...)
{
--- 177,187 ----
sentry __cerb(*this, false);
if (__cerb)
{
+ ios_base::iostate __err = ios_base::iostate(ios_base::goodbit);
try
{
const __num_get_type& __ng = __check_facet(this->_M_num_get);
__ng.get(*this, 0, *this, __err, __n);
}
catch(...)
{
*************** namespace std
*** 191,196 ****
--- 191,197 ----
if ((this->exceptions() & ios_base::badbit) != 0)
__throw_exception_again;
}
+ this->setstate(__err);
}
return *this;
}
*************** namespace std
*** 203,212 ****
sentry __cerb(*this, false);
if (__cerb)
{
try
{
long __l;
- ios_base::iostate __err = ios_base::iostate(ios_base::goodbit);
const __num_get_type& __ng = __check_facet(this->_M_num_get);
__ng.get(*this, 0, *this, __err, __l);
// _GLIBCXX_RESOLVE_LIB_DEFECTS
--- 204,213 ----
sentry __cerb(*this, false);
if (__cerb)
{
+ ios_base::iostate __err = ios_base::iostate(ios_base::goodbit);
try
{
long __l;
const __num_get_type& __ng = __check_facet(this->_M_num_get);
__ng.get(*this, 0, *this, __err, __l);
// _GLIBCXX_RESOLVE_LIB_DEFECTS
*************** namespace std
*** 217,223 ****
__n = __l;
else
__err |= ios_base::failbit;
- this->setstate(__err);
}
catch(...)
{
--- 218,223 ----
*************** namespace std
*** 227,232 ****
--- 227,233 ----
if ((this->exceptions() & ios_base::badbit) != 0)
__throw_exception_again;
}
+ this->setstate(__err);
}
return *this;
}
*************** namespace std
*** 239,250 ****
sentry __cerb(*this, false);
if (__cerb)
{
try
{
- ios_base::iostate __err = ios_base::iostate(ios_base::goodbit);
const __num_get_type& __ng = __check_facet(this->_M_num_get);
__ng.get(*this, 0, *this, __err, __n);
- this->setstate(__err);
}
catch(...)
{
--- 240,250 ----
sentry __cerb(*this, false);
if (__cerb)
{
+ ios_base::iostate __err = ios_base::iostate(ios_base::goodbit);
try
{
const __num_get_type& __ng = __check_facet(this->_M_num_get);
__ng.get(*this, 0, *this, __err, __n);
}
catch(...)
{
*************** namespace std
*** 254,259 ****
--- 254,260 ----
if ((this->exceptions() & ios_base::badbit) != 0)
__throw_exception_again;
}
+ this->setstate(__err);
}
return *this;
}
*************** namespace std
*** 266,277 ****
sentry __cerb(*this, false);
if (__cerb)
{
try
{
- ios_base::iostate __err = ios_base::iostate(ios_base::goodbit);
const __num_get_type& __ng = __check_facet(this->_M_num_get);
__ng.get(*this, 0, *this, __err, __n);
- this->setstate(__err);
}
catch(...)
{
--- 267,277 ----
sentry __cerb(*this, false);
if (__cerb)
{
+ ios_base::iostate __err = ios_base::iostate(ios_base::goodbit);
try
{
const __num_get_type& __ng = __check_facet(this->_M_num_get);
__ng.get(*this, 0, *this, __err, __n);
}
catch(...)
{
*************** namespace std
*** 281,286 ****
--- 281,287 ----
if ((this->exceptions() & ios_base::badbit) != 0)
__throw_exception_again;
}
+ this->setstate(__err);
}
return *this;
}
*************** namespace std
*** 293,304 ****
sentry __cerb(*this, false);
if (__cerb)
{
try
{
- ios_base::iostate __err = ios_base::iostate(ios_base::goodbit);
const __num_get_type& __ng = __check_facet(this->_M_num_get);
__ng.get(*this, 0, *this, __err, __n);
- this->setstate(__err);
}
catch(...)
{
--- 294,304 ----
sentry __cerb(*this, false);
if (__cerb)
{
+ ios_base::iostate __err = ios_base::iostate(ios_base::goodbit);
try
{
const __num_get_type& __ng = __check_facet(this->_M_num_get);
__ng.get(*this, 0, *this, __err, __n);
}
catch(...)
{
*************** namespace std
*** 308,313 ****
--- 308,314 ----
if ((this->exceptions() & ios_base::badbit) != 0)
__throw_exception_again;
}
+ this->setstate(__err);
}
return *this;
}
*************** namespace std
*** 321,332 ****
sentry __cerb(*this, false);
if (__cerb)
{
try
{
- ios_base::iostate __err = ios_base::iostate(ios_base::goodbit);
const __num_get_type& __ng = __check_facet(this->_M_num_get);
__ng.get(*this, 0, *this, __err, __n);
- this->setstate(__err);
}
catch(...)
{
--- 322,332 ----
sentry __cerb(*this, false);
if (__cerb)
{
+ ios_base::iostate __err = ios_base::iostate(ios_base::goodbit);
try
{
const __num_get_type& __ng = __check_facet(this->_M_num_get);
__ng.get(*this, 0, *this, __err, __n);
}
catch(...)
{
*************** namespace std
*** 336,341 ****
--- 336,342 ----
if ((this->exceptions() & ios_base::badbit) != 0)
__throw_exception_again;
}
+ this->setstate(__err);
}
return *this;
}
*************** namespace std
*** 348,359 ****
sentry __cerb(*this, false);
if (__cerb)
{
try
{
- ios_base::iostate __err = ios_base::iostate(ios_base::goodbit);
const __num_get_type& __ng = __check_facet(this->_M_num_get);
__ng.get(*this, 0, *this, __err, __n);
- this->setstate(__err);
}
catch(...)
{
--- 349,359 ----
sentry __cerb(*this, false);
if (__cerb)
{
+ ios_base::iostate __err = ios_base::iostate(ios_base::goodbit);
try
{
const __num_get_type& __ng = __check_facet(this->_M_num_get);
__ng.get(*this, 0, *this, __err, __n);
}
catch(...)
{
*************** namespace std
*** 363,368 ****
--- 363,369 ----
if ((this->exceptions() & ios_base::badbit) != 0)
__throw_exception_again;
}
+ this->setstate(__err);
}
return *this;
}
*************** namespace std
*** 376,387 ****
sentry __cerb(*this, false);
if (__cerb)
{
try
{
- ios_base::iostate __err = ios_base::iostate(ios_base::goodbit);
const __num_get_type& __ng = __check_facet(this->_M_num_get);
__ng.get(*this, 0, *this, __err, __n);
- this->setstate(__err);
}
catch(...)
{
--- 377,387 ----
sentry __cerb(*this, false);
if (__cerb)
{
+ ios_base::iostate __err = ios_base::iostate(ios_base::goodbit);
try
{
const __num_get_type& __ng = __check_facet(this->_M_num_get);
__ng.get(*this, 0, *this, __err, __n);
}
catch(...)
{
*************** namespace std
*** 391,396 ****
--- 391,397 ----
if ((this->exceptions() & ios_base::badbit) != 0)
__throw_exception_again;
}
+ this->setstate(__err);
}
return *this;
}
*************** namespace std
*** 403,414 ****
sentry __cerb(*this, false);
if (__cerb)
{
try
{
- ios_base::iostate __err = ios_base::iostate(ios_base::goodbit);
const __num_get_type& __ng = __check_facet(this->_M_num_get);
__ng.get(*this, 0, *this, __err, __n);
- this->setstate(__err);
}
catch(...)
{
--- 404,414 ----
sentry __cerb(*this, false);
if (__cerb)
{
+ ios_base::iostate __err = ios_base::iostate(ios_base::goodbit);
try
{
const __num_get_type& __ng = __check_facet(this->_M_num_get);
__ng.get(*this, 0, *this, __err, __n);
}
catch(...)
{
*************** namespace std
*** 418,423 ****
--- 418,424 ----
if ((this->exceptions() & ios_base::badbit) != 0)
__throw_exception_again;
}
+ this->setstate(__err);
}
return *this;
}
*************** namespace std
*** 430,441 ****
sentry __cerb(*this, false);
if (__cerb)
{
try
{
- ios_base::iostate __err = ios_base::iostate(ios_base::goodbit);
const __num_get_type& __ng = __check_facet(this->_M_num_get);
__ng.get(*this, 0, *this, __err, __n);
- this->setstate(__err);
}
catch(...)
{
--- 431,441 ----
sentry __cerb(*this, false);
if (__cerb)
{
+ ios_base::iostate __err = ios_base::iostate(ios_base::goodbit);
try
{
const __num_get_type& __ng = __check_facet(this->_M_num_get);
__ng.get(*this, 0, *this, __err, __n);
}
catch(...)
{
*************** namespace std
*** 445,450 ****
--- 445,451 ----
if ((this->exceptions() & ios_base::badbit) != 0)
__throw_exception_again;
}
+ this->setstate(__err);
}
return *this;
}
*************** namespace std
*** 457,468 ****
sentry __cerb(*this, false);
if (__cerb)
{
try
{
- ios_base::iostate __err = ios_base::iostate(ios_base::goodbit);
const __num_get_type& __ng = __check_facet(this->_M_num_get);
__ng.get(*this, 0, *this, __err, __n);
- this->setstate(__err);
}
catch(...)
{
--- 458,468 ----
sentry __cerb(*this, false);
if (__cerb)
{
+ ios_base::iostate __err = ios_base::iostate(ios_base::goodbit);
try
{
const __num_get_type& __ng = __check_facet(this->_M_num_get);
__ng.get(*this, 0, *this, __err, __n);
}
catch(...)
{
*************** namespace std
*** 472,477 ****
--- 472,478 ----
if ((this->exceptions() & ios_base::badbit) != 0)
__throw_exception_again;
}
+ this->setstate(__err);
}
return *this;
}