diff options
author | Jerry Quinn <jlquinn@optonline.net> | 2004-01-27 15:45:43 +0000 |
---|---|---|
committer | Jerry Quinn <jlquinn@gcc.gnu.org> | 2004-01-27 15:45:43 +0000 |
commit | 2a837cf80316570aaad5bf93b10655bb62ae67ad (patch) | |
tree | e4ec8a4b95333d1b256de1ca1fd838fec57141c9 /libstdc++-v3/src/ios.cc | |
parent | 6e198ee05d37cde3bd5f32839c6ad4e01a679911 (diff) | |
download | gcc-2a837cf80316570aaad5bf93b10655bb62ae67ad.zip gcc-2a837cf80316570aaad5bf93b10655bb62ae67ad.tar.gz gcc-2a837cf80316570aaad5bf93b10655bb62ae67ad.tar.bz2 |
re PR libstdc++/11584 (ios::iword() fails to zero-initialize storage on failure)
2004-01-27 Jerry Quinn <jlquinn@optonline.net>
PR libstdc++/11584
* include/bits/ios_base.h (ios_base::_M_grow_words): Add
iword/pword selector.
(ios_base::iword, ios_base::pword): Use it.
* src/ios.cc (ios_base::_M_grow_words): Clear _M_word_zero
iword or pword member on alloc failure.
* testsuite/27_io/ios_base/storage/11584.cc: New test.
From-SVN: r76725
Diffstat (limited to 'libstdc++-v3/src/ios.cc')
-rw-r--r-- | libstdc++-v3/src/ios.cc | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/libstdc++-v3/src/ios.cc b/libstdc++-v3/src/ios.cc index 0dec323..6f987c2 100644 --- a/libstdc++-v3/src/ios.cc +++ b/libstdc++-v3/src/ios.cc @@ -147,7 +147,7 @@ namespace std // 27.4.2.5 iword/pword storage ios_base::_Words& - ios_base::_M_grow_words(int ix) + ios_base::_M_grow_words(int ix, bool iword) { // Precondition: _M_word_size <= ix int newsize = _S_local_word_size; @@ -165,6 +165,10 @@ namespace std if (_M_streambuf_state & _M_exception) __throw_ios_failure(__N("ios_base::_M_grow_words " "allocation failed")); + if (iword) + _M_word_zero._M_iword = 0; + else + _M_word_zero._M_pword = 0; return _M_word_zero; } for (int i = 0; i < _M_word_size; i++) @@ -180,6 +184,10 @@ namespace std _M_streambuf_state |= badbit; if (_M_streambuf_state & _M_exception) __throw_ios_failure(__N("ios_base::_M_grow_words is not valid")); + if (iword) + _M_word_zero._M_iword = 0; + else + _M_word_zero._M_pword = 0; return _M_word_zero; } } |