summaryrefslogtreecommitdiff
path: root/libstdc++-v3
diff options
context:
space:
mode:
authorpaolo <paolo@138bc75d-0d04-0410-961f-82ee72b054a4>2003-02-12 19:39:19 +0000
committerpaolo <paolo@138bc75d-0d04-0410-961f-82ee72b054a4>2003-02-12 19:39:19 +0000
commit25dc5de79662a4a855cb2e3f9f3a11a6bf664b40 (patch)
tree189943f8946e67b013c29727d5024f7450b66902 /libstdc++-v3
parent760c3e427d5d789359c8672bb63ee27781a30d54 (diff)
downloadgcc-25dc5de79662a4a855cb2e3f9f3a11a6bf664b40.tar.gz
2003-02-12 Paolo Carlini <pcarlini@unitus.it>
PR libstdc++/9563 * include/bits/ostream.tcc (sentry::sentry): Check the state of the stream after the preparation. * testsuite/27_io/ostream_sentry.cc (test02): Add. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@62779 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libstdc++-v3')
-rw-r--r--libstdc++-v3/ChangeLog7
-rw-r--r--libstdc++-v3/include/bits/ostream.tcc16
-rw-r--r--libstdc++-v3/testsuite/27_io/ostream_sentry.cc32
3 files changed, 51 insertions, 4 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog
index d91f7bff42a..1cefd52a72f 100644
--- a/libstdc++-v3/ChangeLog
+++ b/libstdc++-v3/ChangeLog
@@ -1,3 +1,10 @@
+2003-02-12 Paolo Carlini <pcarlini@unitus.it>
+
+ PR libstdc++/9563
+ * include/bits/ostream.tcc (sentry::sentry): Check
+ the state of the stream after the preparation.
+ * testsuite/27_io/ostream_sentry.cc (test02): Add.
+
2003-02-11 Benjamin Kosnik <bkoz@redhat.com>
* include/Makefile.am (stamp-std-precompile): Add rule.
diff --git a/libstdc++-v3/include/bits/ostream.tcc b/libstdc++-v3/include/bits/ostream.tcc
index b5b8762e5bf..3456e679082 100644
--- a/libstdc++-v3/include/bits/ostream.tcc
+++ b/libstdc++-v3/include/bits/ostream.tcc
@@ -41,11 +41,19 @@ namespace std
template<typename _CharT, typename _Traits>
basic_ostream<_CharT, _Traits>::sentry::
sentry(basic_ostream<_CharT,_Traits>& __os)
- : _M_ok(__os.good()), _M_os(__os)
+ : _M_os(__os)
{
- // XXX MT
- if (_M_ok && __os.tie())
- __os.tie()->flush();
+ // XXX MT
+ if (__os.good() && __os.tie())
+ __os.tie()->flush();
+
+ if (__os.good())
+ _M_ok = true;
+ else
+ {
+ _M_ok = false;
+ __os.setstate(ios_base::failbit);
+ }
}
template<typename _CharT, typename _Traits>
diff --git a/libstdc++-v3/testsuite/27_io/ostream_sentry.cc b/libstdc++-v3/testsuite/27_io/ostream_sentry.cc
index cba75f250fa..322dbc55057 100644
--- a/libstdc++-v3/testsuite/27_io/ostream_sentry.cc
+++ b/libstdc++-v3/testsuite/27_io/ostream_sentry.cc
@@ -46,8 +46,40 @@ test01()
VERIFY( bool(sentry1) == true );
}
+// libstdc++/9563
+struct buf: std::streambuf
+{
+ std::ios *io_;
+
+ buf (std::ios *io): io_ (io) { }
+
+ virtual int sync ()
+ {
+ io_->setstate (std::ios::failbit);
+ return 0;
+ }
+};
+
+void
+test02()
+{
+ bool test = true;
+
+ buf b(0);
+ std::ostream strm(&b);
+
+ buf tb(&strm);
+ std::ostream tied(&tb);
+
+ strm.tie(&tied);
+ std::ostream::sentry s(strm);
+
+ VERIFY( !s );
+}
+
int main()
{
test01();
+ test02();
return 0;
}