aboutsummaryrefslogtreecommitdiff
path: root/libstdc++-v3/testsuite
diff options
context:
space:
mode:
authorPaolo Carlini <pcarlini@suse.de>2006-02-17 10:46:57 +0000
committerPaolo Carlini <paolo@gcc.gnu.org>2006-02-17 10:46:57 +0000
commit10d9600d586390e6e30d0d731ad127b76a90a62e (patch)
tree7d5556d4cc5632af4f60606bdc602c9e59bb2854 /libstdc++-v3/testsuite
parentb16caf72c73fd21bc729b9f039869800194bb1a0 (diff)
downloadgcc-10d9600d586390e6e30d0d731ad127b76a90a62e.zip
gcc-10d9600d586390e6e30d0d731ad127b76a90a62e.tar.gz
gcc-10d9600d586390e6e30d0d731ad127b76a90a62e.tar.bz2
re PR libstdc++/26250 (stringbuf::overflow() fails to set egptr() same as epptr())
2006-02-17 Paolo Carlini <pcarlini@suse.de> Howard Hinnant <hhinnant@apple.com> PR libstdc++/26250 * include/bits/sstream.tcc (basic_stringbuf<>::overflow): Tweak to leave epgtr() just past the new write position, as per the relevant bits of 27.7.1.3/8 (not changed by DR 432). * testsuite/27_io/basic_stringbuf/overflow/char/26250.cc: New. * testsuite/27_io/basic_stringbuf/overflow/wchar_t/26250.cc: Same. * docs/html/ext/howto.html: Add entries for DR 169 and DR 432. * include/std/std_sstream.h (basic_stringbuf<>::_M_sync): Move out of line... * include/bits/sstream.tcc: ... here. Co-Authored-By: Howard Hinnant <hhinnant@apple.com> From-SVN: r111177
Diffstat (limited to 'libstdc++-v3/testsuite')
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_stringbuf/overflow/char/26250.cc58
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_stringbuf/overflow/wchar_t/26250.cc58
2 files changed, 116 insertions, 0 deletions
diff --git a/libstdc++-v3/testsuite/27_io/basic_stringbuf/overflow/char/26250.cc b/libstdc++-v3/testsuite/27_io/basic_stringbuf/overflow/char/26250.cc
new file mode 100644
index 0000000..bf7dcde
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_stringbuf/overflow/char/26250.cc
@@ -0,0 +1,58 @@
+// Copyright (C) 2006 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 2, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING. If not, write to the Free
+// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+// USA.
+
+// 27.8.1.4 Overridden virtual functions
+
+#include <sstream>
+#include <testsuite_hooks.h>
+
+struct pubbuf
+: std::stringbuf
+{
+ using std::stringbuf::eback;
+ using std::stringbuf::egptr;
+ using std::stringbuf::pbase;
+ using std::stringbuf::pptr;
+ using std::stringbuf::epptr;
+ using std::stringbuf::overflow;
+};
+
+// libstdc++/26250
+void test01()
+{
+ bool test __attribute__((unused)) = true;
+
+ pubbuf buf;
+
+ VERIFY( buf.overflow('x') == 'x' );
+ VERIFY( buf.pptr() - buf.pbase() == 1 );
+
+ // not required but good for efficiency
+ // NB: we are implementing DR 169 and DR 432
+ const int write_positions = buf.epptr() - buf.pbase();
+ VERIFY( write_positions > 1 );
+
+ // 27.7.1.3, p8:
+ VERIFY( buf.egptr() - buf.eback() == 1 );
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_stringbuf/overflow/wchar_t/26250.cc b/libstdc++-v3/testsuite/27_io/basic_stringbuf/overflow/wchar_t/26250.cc
new file mode 100644
index 0000000..c835ea9
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_stringbuf/overflow/wchar_t/26250.cc
@@ -0,0 +1,58 @@
+// Copyright (C) 2006 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 2, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING. If not, write to the Free
+// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+// USA.
+
+// 27.8.1.4 Overridden virtual functions
+
+#include <sstream>
+#include <testsuite_hooks.h>
+
+struct pubbuf
+: std::wstringbuf
+{
+ using std::wstringbuf::eback;
+ using std::wstringbuf::egptr;
+ using std::wstringbuf::pbase;
+ using std::wstringbuf::pptr;
+ using std::wstringbuf::epptr;
+ using std::wstringbuf::overflow;
+};
+
+// libstdc++/26250
+void test01()
+{
+ bool test __attribute__((unused)) = true;
+
+ pubbuf buf;
+
+ VERIFY( buf.overflow(L'x') == L'x' );
+ VERIFY( buf.pptr() - buf.pbase() == 1 );
+
+ // not required but good for efficiency
+ // NB: we are implementing DR 169 and DR 432
+ const int write_positions = buf.epptr() - buf.pbase();
+ VERIFY( write_positions > 1 );
+
+ // 27.7.1.3, p8:
+ VERIFY( buf.egptr() - buf.eback() == 1 );
+}
+
+int main()
+{
+ test01();
+ return 0;
+}