From: Benjamin Kosnik Date: Tue, 26 Feb 2002 04:55:48 +0000 (+0000) Subject: ios.cc (ios_base::~ios_base): Tweak. X-Git-Tag: prereleases/libstdc++-3.0.97~155 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=1bc59af523f6fa2eefc7601bde3d1b15218e2f40;p=thirdparty%2Fgcc.git ios.cc (ios_base::~ios_base): Tweak. 2002-02-25 Benjamin Kosnik * src/ios.cc (ios_base::~ios_base): Tweak. (ios_base::_M_call_callbacks): Deal with null __p. (ios_base::ios_base): Set _M_callbacks. * include/bits/basic_ios.tcc (basic_ios::init): Adjust comment. * testsuite/27_io/ios_init.cc (test02): Fix. * mkcheck.in (static_fail): Failed links go to output file. From-SVN: r50032 --- diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index eceef8983ca5..12baa5731327 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,13 @@ +2002-02-25 Benjamin Kosnik + + * src/ios.cc (ios_base::~ios_base): Tweak. + (ios_base::_M_call_callbacks): Deal with null __p. + (ios_base::ios_base): Set _M_callbacks. + * include/bits/basic_ios.tcc (basic_ios::init): Adjust comment. + * testsuite/27_io/ios_init.cc (test02): Fix. + + * mkcheck.in (static_fail): Failed links go to output file. + 2002-02-25 Phil Edwards * docs/html/faq/index.html: Update. diff --git a/libstdc++-v3/include/bits/basic_ios.tcc b/libstdc++-v3/include/bits/basic_ios.tcc index 4db4a82d5aca..b4f523f54835 100644 --- a/libstdc++-v3/include/bits/basic_ios.tcc +++ b/libstdc++-v3/include/bits/basic_ios.tcc @@ -148,12 +148,12 @@ namespace std // requirements after basic_ios::init() has been called. As part // of this, fill() must return widen(' '), which needs an imbued // ctype facet of char_type to return without throwing an - // exception. This is not a required facet, so streams with - // char_type != [char, wchar_t] will not have it by - // default. However, because fill()'s signature is const, this - // data member cannot be lazily initialized. Thus, thoughts of - // using a non-const helper function in ostream inserters is - // really besides the point. + // exception. Unfortunately, ctype is not necessarily a + // required facet, so streams with char_type != [char, wchar_t] + // will not have it by default. However, because fill()'s + // signature is const, this data member cannot be lazily + // initialized. Thus, thoughts of using a non-const helper + // function in ostream inserters is really besides the point. _M_fill = this->widen(' '); _M_exception = goodbit; diff --git a/libstdc++-v3/include/bits/ios_base.h b/libstdc++-v3/include/bits/ios_base.h index 7525e7d6f4cd..2cc959b1c273 100644 --- a/libstdc++-v3/include/bits/ios_base.h +++ b/libstdc++-v3/include/bits/ios_base.h @@ -277,7 +277,7 @@ namespace std }; static const int _S_local_words = 8; - _Words _M_word_array[_S_local_words]; // Guaranteed storage + _Words _M_word_array[_S_local_words]; // Guaranteed storage. _Words _M_dummy; // Only for failed iword/pword calls. _Words* _M_words; int _M_word_limit; diff --git a/libstdc++-v3/mkcheck.in b/libstdc++-v3/mkcheck.in index c65a144c2c88..b104244dba61 100755 --- a/libstdc++-v3/mkcheck.in +++ b/libstdc++-v3/mkcheck.in @@ -362,8 +362,8 @@ test_file() else # the file did not compile/link. printf "\n" >> $LOG_FILE -# `cat compile.out >> $LOG_FILE` -# rm compile.out + `cat compile.out >> $LOG_FILE` + rm compile.out RESULT="-b" TEXT="0" DATA="0" diff --git a/libstdc++-v3/src/ios.cc b/libstdc++-v3/src/ios.cc index e8122bb2b77b..9824b10223a6 100644 --- a/libstdc++-v3/src/ios.cc +++ b/libstdc++-v3/src/ios.cc @@ -257,7 +257,7 @@ namespace std } for (; i < _M_word_limit; i++) words[i] = _M_words[i]; - if (_M_words != _M_word_array) + if (_M_words && _M_words != _M_word_array) delete [] _M_words; } @@ -294,7 +294,11 @@ namespace std ios_base::ios_base() { - // Do nothing; init() does it. Static init to 0 makes everything sane. + // Do nothing: basic_ios::init() does it. + // NB: _M_callbacks and _M_words must be zero for non-initialized + // ios_base to go through ~ios_base gracefully. + _M_callbacks = 0; + _M_words = 0; } // 27.4.2.7 ios_base constructors/destructors @@ -302,9 +306,8 @@ namespace std { _M_call_callbacks(erase_event); _M_dispose_callbacks(); - if (_M_words != _M_word_array) + if (_M_words && _M_words != _M_word_array) delete [] _M_words; - // XXX done? } void @@ -314,13 +317,14 @@ namespace std void ios_base::_M_call_callbacks(event __e) throw() { - for (_Callback_list* __p = _M_callbacks; __p; __p = __p->_M_next) + _Callback_list* __p = _M_callbacks; + while (__p) { - try { - (*__p->_M_fn) (__e, *this, __p->_M_index); - } - catch (...) { - } + try + { (*__p->_M_fn) (__e, *this, __p->_M_index); } + catch (...) + { } + __p = __p->_M_next; } } diff --git a/libstdc++-v3/testsuite/27_io/ios_init.cc b/libstdc++-v3/testsuite/27_io/ios_init.cc index 626439bdb8bb..9f87ee0d32e5 100644 --- a/libstdc++-v3/testsuite/27_io/ios_init.cc +++ b/libstdc++-v3/testsuite/27_io/ios_init.cc @@ -86,6 +86,9 @@ void test01() // by default, into the locale object. As such, basic_ios::init is // required to return a bad_cast for the first use of fill() call. // See 27.4.4.1 + +class gnu_ios: public std::basic_ios { }; + void test02() { bool test = true; @@ -93,7 +96,7 @@ void test02() // 01: Doesn't call basic_ios::init, which uses ctype.. try { - std::basic_ostringstream oss; + gnu_ios gios; } catch(...) { @@ -122,7 +125,7 @@ void test02() } catch(const std::bad_cast& obj) { - test = true; + // This is correct. } catch(...) {