summaryrefslogtreecommitdiff
path: root/libstdc++-v3/testsuite/27_io/basic_filebuf/overflow
diff options
context:
space:
mode:
authorupstream source tree <ports@midipix.org>2015-03-15 20:14:05 -0400
committerupstream source tree <ports@midipix.org>2015-03-15 20:14:05 -0400
commit554fd8c5195424bdbcabf5de30fdc183aba391bd (patch)
tree976dc5ab7fddf506dadce60ae936f43f58787092 /libstdc++-v3/testsuite/27_io/basic_filebuf/overflow
downloadcbb-gcc-4.6.4-554fd8c5195424bdbcabf5de30fdc183aba391bd.tar.bz2
cbb-gcc-4.6.4-554fd8c5195424bdbcabf5de30fdc183aba391bd.tar.xz
obtained gcc-4.6.4.tar.bz2 from upstream website;upstream
verified gcc-4.6.4.tar.bz2.sig; imported gcc-4.6.4 source tree from verified upstream tarball. downloading a git-generated archive based on the 'upstream' tag should provide you with a source tree that is binary identical to the one extracted from the above tarball. if you have obtained the source via the command 'git clone', however, do note that line-endings of files in your working directory might differ from line-endings of the respective files in the upstream repository.
Diffstat (limited to 'libstdc++-v3/testsuite/27_io/basic_filebuf/overflow')
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_filebuf/overflow/char/1.cc70
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_filebuf/overflow/char/13858.cc69
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_filebuf/overflow/char/2-unbuf.cc55
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_filebuf/overflow/char/2.cc54
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_filebuf/overflow/char/3599.cc58
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_filebuf/overflow/char/9169.cc73
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_filebuf/overflow/char/9182-2.cc80
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_filebuf/overflow/char/9988.cc70
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_filebuf/overflow/wchar_t/11305-1.cc47
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_filebuf/overflow/wchar_t/11305-2.cc49
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_filebuf/overflow/wchar_t/11305-3.cc46
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_filebuf/overflow/wchar_t/11305-4.cc48
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_filebuf/overflow/wchar_t/13858.cc70
13 files changed, 789 insertions, 0 deletions
diff --git a/libstdc++-v3/testsuite/27_io/basic_filebuf/overflow/char/1.cc b/libstdc++-v3/testsuite/27_io/basic_filebuf/overflow/char/1.cc
new file mode 100644
index 000000000..7c6874313
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_filebuf/overflow/char/1.cc
@@ -0,0 +1,70 @@
+// 1999-10-11 bkoz
+
+// Copyright (C) 1999, 2000, 2001, 2002, 2003, 2009
+// 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 3, 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 COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+
+#include <fstream>
+#include <ostream>
+#include <testsuite_hooks.h>
+
+// test03
+// http://gcc.gnu.org/ml/libstdc++/2000-q1/msg00151.html
+template<typename charT, typename traits = std::char_traits<charT> >
+ class basic_nullbuf : public std::basic_filebuf<charT, traits>
+ {
+ protected:
+ typedef typename
+ std::basic_filebuf<charT, traits>::int_type int_type;
+ virtual int_type
+ overflow(int_type c)
+ { return traits::not_eof(c); }
+ };
+
+typedef basic_nullbuf<char> nullbuf;
+
+template<typename T>
+ char
+ print(const T& x)
+ {
+ nullbuf ob;
+ std::ostream out(&ob);
+ out << x << std::endl;
+ return (!out ? '0' : '1');
+ }
+
+void test03()
+{
+ bool test __attribute__((unused)) = true;
+ const std::string control01("11111");
+ std::string test01;
+
+ test01 += print(true);
+ test01 += print(3.14159);
+ test01 += print(10);
+ test01 += print('x');
+ test01 += print("pipo");
+
+ VERIFY( test01 == control01 );
+}
+
+int main()
+{
+ test03();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_filebuf/overflow/char/13858.cc b/libstdc++-v3/testsuite/27_io/basic_filebuf/overflow/char/13858.cc
new file mode 100644
index 000000000..27f7b3664
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_filebuf/overflow/char/13858.cc
@@ -0,0 +1,69 @@
+// 2004-02-14 Petur Runolfsson <peturr02@ru.is>
+
+// Copyright (C) 2004, 2009 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 3, 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 COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// 27.8.1.4 Overridden virtual functions
+
+#include <fstream>
+#include <locale>
+
+class Cvt : public std::codecvt<char, char, std::mbstate_t>
+{
+protected:
+ virtual std::codecvt_base::result
+ do_out(std::mbstate_t&, const char* from, const char*,
+ const char*& from_next, char* to, char*, char*& to_next) const
+ {
+ from_next = from;
+ to_next = to;
+ return std::codecvt_base::error;
+ }
+
+ virtual bool
+ do_always_noconv() const throw()
+ { return false; }
+};
+
+// libstdc++/13858
+void test01()
+{
+ using namespace std;
+
+ filebuf fb;
+ fb.pubimbue(locale(locale::classic(), new Cvt));
+ fb.open("tmp_13858_char", ios_base::out);
+
+ try
+ {
+ fb.sputc('a');
+ fb.sputc('b');
+ fb.pubimbue(locale::classic());
+ fb.sputc('c');
+ fb.pubsync();
+ fb.close();
+ }
+ catch (std::exception&)
+ {
+ }
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_filebuf/overflow/char/2-unbuf.cc b/libstdc++-v3/testsuite/27_io/basic_filebuf/overflow/char/2-unbuf.cc
new file mode 100644
index 000000000..792b7970a
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_filebuf/overflow/char/2-unbuf.cc
@@ -0,0 +1,55 @@
+// 2003-06-10 Paolo Carlini <pcarlini@unitus.it>
+
+// Copyright (C) 2003, 2009 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 3, 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 COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// 27.8.1.4 Overridden virtual functions
+
+// { dg-require-fileio "" }
+
+#include <fstream>
+#include <testsuite_hooks.h>
+
+const char name_08[] = "filebuf_virtuals-8.txt"; // empty file, need to create
+
+class OverBuf : public std::filebuf
+{
+public:
+ int_type pub_overflow(int_type c = traits_type::eof())
+ { return std::filebuf::overflow(c); }
+};
+
+// According to 27.5.2.4.5 filebuf::overflow() returns not_eof(eof()).
+void test01()
+{
+ using namespace std;
+ bool test __attribute__((unused)) = true;
+ typedef OverBuf::traits_type traits_type;
+
+ OverBuf fb;
+ fb.pubsetbuf(0, 0);
+ fb.open(name_08, ios_base::out | ios_base::trunc);
+
+ VERIFY( fb.pub_overflow() == traits_type::not_eof(traits_type::eof()) );
+ fb.close();
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_filebuf/overflow/char/2.cc b/libstdc++-v3/testsuite/27_io/basic_filebuf/overflow/char/2.cc
new file mode 100644
index 000000000..1cb8e503d
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_filebuf/overflow/char/2.cc
@@ -0,0 +1,54 @@
+// 2003-06-10 Paolo Carlini <pcarlini@unitus.it>
+
+// Copyright (C) 2003, 2009 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 3, 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 COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// 27.8.1.4 Overridden virtual functions
+
+// { dg-require-fileio "" }
+
+#include <fstream>
+#include <testsuite_hooks.h>
+
+const char name_08[] = "filebuf_virtuals-8.txt"; // empty file, need to create
+
+class OverBuf : public std::filebuf
+{
+public:
+ int_type pub_overflow(int_type c = traits_type::eof())
+ { return std::filebuf::overflow(c); }
+};
+
+// According to 27.5.2.4.5 filebuf::overflow() returns not_eof(eof()).
+void test01()
+{
+ using namespace std;
+ bool test __attribute__((unused)) = true;
+ typedef OverBuf::traits_type traits_type;
+
+ OverBuf fb;
+ fb.open(name_08, ios_base::out | ios_base::trunc);
+
+ VERIFY( fb.pub_overflow() == traits_type::not_eof(traits_type::eof()) );
+ fb.close();
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_filebuf/overflow/char/3599.cc b/libstdc++-v3/testsuite/27_io/basic_filebuf/overflow/char/3599.cc
new file mode 100644
index 000000000..d02872cc0
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_filebuf/overflow/char/3599.cc
@@ -0,0 +1,58 @@
+// 1999-10-11 bkoz
+
+// Copyright (C) 1999, 2000, 2001, 2002, 2003, 2009
+// 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 3, 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 COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+
+#include <fstream>
+#include <ostream>
+#include <testsuite_hooks.h>
+
+// libstdc++/3599
+class testbuf : public std::filebuf
+{
+public:
+ typedef std::filebuf::traits_type traits_type;
+
+ testbuf() : std::filebuf() { }
+
+protected:
+ int_type
+ overflow(int_type c __attribute__((unused)) = traits_type::eof())
+ { return traits_type::not_eof(0); }
+};
+
+void
+test07()
+{
+ bool test __attribute__((unused)) = true;
+ testbuf ob;
+ std::ostream out(&ob);
+
+ out << "gasp";
+ VERIFY(out.good());
+
+ out << std::endl;
+ VERIFY(out.good());
+}
+
+int main()
+{
+ test07();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_filebuf/overflow/char/9169.cc b/libstdc++-v3/testsuite/27_io/basic_filebuf/overflow/char/9169.cc
new file mode 100644
index 000000000..239c79a65
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_filebuf/overflow/char/9169.cc
@@ -0,0 +1,73 @@
+// 2001-05-21 Benjamin Kosnik <bkoz@redhat.com>
+
+// Copyright (C) 2001, 2002, 2003, 2009 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 3, 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 COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// 27.8.1.4 Overridden virtual functions
+
+// { dg-require-fileio "" }
+
+#include <fstream>
+#include <locale>
+#include <testsuite_hooks.h>
+
+const char name_04[] = "filebuf_virtuals-4.txt"; // empty file, need to create
+
+class Cvt_to_upper : public std::codecvt<char, char, mbstate_t>
+{
+ bool do_always_noconv() const throw()
+ {
+ return false;
+ }
+};
+
+// libstdc++/9169
+// filebuf output fails if codecvt<>::out returns noconv
+void test10()
+{
+ using namespace std;
+ bool test __attribute__((unused)) = true;
+
+ locale c_loc = locale::classic();
+ locale loc(c_loc, new Cvt_to_upper);
+
+ string str("abcdefghijklmnopqrstuvwxyz");
+ string tmp;
+
+ {
+ ofstream out;
+ out.imbue(loc);
+ out.open(name_04);
+ copy(str.begin(), str.end(), ostreambuf_iterator<char>(out));
+ }
+
+ {
+ ifstream in;
+ in.open(name_04);
+ copy(istreambuf_iterator<char>(in), istreambuf_iterator<char>(),
+ back_inserter(tmp));
+ }
+
+ VERIFY( tmp.size() == str.size() );
+ VERIFY( tmp == str );
+}
+
+int main()
+{
+ test10();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_filebuf/overflow/char/9182-2.cc b/libstdc++-v3/testsuite/27_io/basic_filebuf/overflow/char/9182-2.cc
new file mode 100644
index 000000000..80d001199
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_filebuf/overflow/char/9182-2.cc
@@ -0,0 +1,80 @@
+// 2001-05-21 Benjamin Kosnik <bkoz@redhat.com>
+
+// Copyright (C) 2001, 2002, 2003, 2004, 2009 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 3, 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 COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// 27.8.1.4 Overridden virtual functions
+
+// { dg-require-fileio "" }
+
+#include <fstream>
+#include <locale>
+#include <testsuite_hooks.h>
+
+const char name_07[] = "filebuf_virtuals-7.txt"; // empty file, need to create
+
+class errorcvt : public std::codecvt<char, char, mbstate_t>
+{
+protected:
+ std::codecvt_base::result
+ do_out(mbstate_t&, const char* from, const char*,
+ const char*& from_next, char* to, char*,
+ char*& to_next) const
+ {
+ from_next = from;
+ to_next = to;
+ return std::codecvt<char, char, mbstate_t>::error;
+ }
+
+ virtual bool do_always_noconv() const throw()
+ {
+ return false;
+ }
+};
+
+// libstdc++/9182
+// basic_filebuf<>::sync and overflow do not write out any characters
+// if codecvt<>::out returns error
+void test14()
+{
+ using namespace std;
+ bool test __attribute__((unused)) = true;
+
+ locale loc = locale::classic();
+ loc = locale(loc, new errorcvt);
+
+ filebuf fbuf1;
+ fbuf1.pubimbue(loc);
+ fbuf1.pubsetbuf(0, 0);
+ fbuf1.open(name_07, ios_base::out | ios_base::trunc);
+
+ try
+ {
+ fbuf1.sputn("onne", 4);
+ fbuf1.close();
+ VERIFY( false );
+ }
+ catch (std::exception&)
+ {
+ }
+}
+
+int main()
+{
+ test14();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_filebuf/overflow/char/9988.cc b/libstdc++-v3/testsuite/27_io/basic_filebuf/overflow/char/9988.cc
new file mode 100644
index 000000000..74dd04bb8
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_filebuf/overflow/char/9988.cc
@@ -0,0 +1,70 @@
+// 2001-05-21 Benjamin Kosnik <bkoz@redhat.com>
+
+// Copyright (C) 2001, 2002, 2003, 2009 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 3, 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 COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// 27.8.1.4 Overridden virtual functions
+
+// { dg-require-fileio "" }
+
+#include <fstream>
+#include <testsuite_hooks.h>
+
+const char name_08[] = "filebuf_virtuals-8.txt"; // empty file, need to create
+
+class OverBuf : public std::filebuf
+{
+public:
+ int_type pub_overflow(int_type c = traits_type::eof())
+ { return std::filebuf::overflow(c); }
+};
+
+// libstdc++/9988
+// filebuf::overflow writes EOF to file
+void test15()
+{
+ using namespace std;
+ bool test __attribute__((unused)) = true;
+
+ OverBuf fb;
+ fb.open(name_08, ios_base::out | ios_base::trunc);
+
+ fb.sputc('a');
+ fb.pub_overflow('b');
+ fb.pub_overflow();
+ fb.sputc('c');
+ fb.close();
+
+ filebuf fbin;
+ fbin.open(name_08, ios_base::in);
+ filebuf::int_type c;
+ c = fbin.sbumpc();
+ VERIFY( c == 'a' );
+ c = fbin.sbumpc();
+ VERIFY( c == 'b' );
+ c = fbin.sbumpc();
+ VERIFY( c == 'c' );
+ c = fbin.sbumpc();
+ VERIFY( c == filebuf::traits_type::eof() );
+ fbin.close();
+}
+
+int main()
+{
+ test15();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_filebuf/overflow/wchar_t/11305-1.cc b/libstdc++-v3/testsuite/27_io/basic_filebuf/overflow/wchar_t/11305-1.cc
new file mode 100644
index 000000000..7faa0501a
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_filebuf/overflow/wchar_t/11305-1.cc
@@ -0,0 +1,47 @@
+// { dg-require-namedlocale "en_US.UTF-8" }
+
+// Copyright (C) 2003, 2005, 2009, 2010 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 3, 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 COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// 27.8.1.4 Overridden virtual functions
+
+#include <fstream>
+#include <locale>
+#include <testsuite_hooks.h>
+
+void test01()
+{
+ using namespace std;
+ bool test __attribute__((unused)) = true;
+
+ wfilebuf fb;
+ locale loc(locale("en_US.UTF-8"));
+ fb.pubimbue(loc);
+ fb.pubsetbuf(0, 0);
+ fb.open("tmp_11305-1", ios_base::out);
+ wfilebuf::int_type n1 = fb.sputc(0x20000000);
+ wfilebuf* f = fb.close();
+
+ VERIFY( n1 != wfilebuf::traits_type::eof() );
+ VERIFY( f );
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_filebuf/overflow/wchar_t/11305-2.cc b/libstdc++-v3/testsuite/27_io/basic_filebuf/overflow/wchar_t/11305-2.cc
new file mode 100644
index 000000000..e4a726a0d
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_filebuf/overflow/wchar_t/11305-2.cc
@@ -0,0 +1,49 @@
+// { dg-require-namedlocale "en_US.UTF-8" }
+
+// Copyright (C) 2003, 2005, 2009, 2010 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 3, 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 COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// 27.8.1.4 Overridden virtual functions
+
+#include <fstream>
+#include <locale>
+#include <testsuite_hooks.h>
+
+void test02()
+{
+ using namespace std;
+ bool test __attribute__((unused)) = true;
+
+ wfilebuf fb;
+ locale loc(locale("en_US.UTF-8"));
+ fb.pubimbue(loc);
+ fb.pubsetbuf(0, 0);
+ fb.open("tmp_11305-2", ios_base::out);
+ wfilebuf::int_type n1 = fb.sputc(0x20000000);
+ wfilebuf::int_type n2 = fb.sputc(0x40000000);
+ wfilebuf* f = fb.close();
+
+ VERIFY( n1 != wfilebuf::traits_type::eof() );
+ VERIFY( n2 != wfilebuf::traits_type::eof() );
+ VERIFY( f );
+}
+
+int main()
+{
+ test02();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_filebuf/overflow/wchar_t/11305-3.cc b/libstdc++-v3/testsuite/27_io/basic_filebuf/overflow/wchar_t/11305-3.cc
new file mode 100644
index 000000000..5d49ed0df
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_filebuf/overflow/wchar_t/11305-3.cc
@@ -0,0 +1,46 @@
+// { dg-require-namedlocale "en_US.UTF-8" }
+
+// Copyright (C) 2003, 2005, 2009, 2010 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 3, 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 COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// 27.8.1.4 Overridden virtual functions
+
+#include <fstream>
+#include <locale>
+#include <testsuite_hooks.h>
+
+void test03()
+{
+ using namespace std;
+ bool test __attribute__((unused)) = true;
+
+ wfilebuf fb;
+ locale loc(locale("en_US.UTF-8"));
+ fb.pubimbue(loc);
+ fb.open("tmp_11305-3", ios_base::out);
+ wfilebuf::int_type n1 = fb.sputc(0x20000000);
+ wfilebuf* f = fb.close();
+
+ VERIFY( n1 != wfilebuf::traits_type::eof() );
+ VERIFY( f );
+}
+
+int main()
+{
+ test03();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_filebuf/overflow/wchar_t/11305-4.cc b/libstdc++-v3/testsuite/27_io/basic_filebuf/overflow/wchar_t/11305-4.cc
new file mode 100644
index 000000000..3076a1777
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_filebuf/overflow/wchar_t/11305-4.cc
@@ -0,0 +1,48 @@
+// { dg-require-namedlocale "en_US.UTF-8" }
+
+// Copyright (C) 2003, 2005, 2009, 2010 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 3, 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 COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// 27.8.1.4 Overridden virtual functions
+
+#include <fstream>
+#include <locale>
+#include <testsuite_hooks.h>
+
+void test04()
+{
+ using namespace std;
+ bool test __attribute__((unused)) = true;
+
+ wfilebuf fb;
+ locale loc(locale("en_US.UTF-8"));
+ fb.pubimbue(loc);
+ fb.open("tmp_11405-4", ios_base::out);
+ wfilebuf::int_type n1 = fb.sputc(0x20000000);
+ wfilebuf::int_type n2 = fb.sputc(0x40000000);
+ wfilebuf* f = fb.close();
+
+ VERIFY( n1 != wfilebuf::traits_type::eof() );
+ VERIFY( n2 != wfilebuf::traits_type::eof() );
+ VERIFY( f );
+}
+
+int main()
+{
+ test04();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_filebuf/overflow/wchar_t/13858.cc b/libstdc++-v3/testsuite/27_io/basic_filebuf/overflow/wchar_t/13858.cc
new file mode 100644
index 000000000..dd745267a
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_filebuf/overflow/wchar_t/13858.cc
@@ -0,0 +1,70 @@
+// 2004-02-14 Petur Runolfsson <peturr02@ru.is>
+
+// Copyright (C) 2004, 2009 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 3, 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 COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// 27.8.1.4 Overridden virtual functions
+
+#include <fstream>
+#include <locale>
+
+class Cvt : public std::codecvt<wchar_t, char, std::mbstate_t>
+{
+protected:
+ virtual std::codecvt_base::result
+ do_out(std::mbstate_t&, const wchar_t* from, const wchar_t*,
+ const wchar_t*& from_next, char* to, char*,
+ char*& to_next) const
+ {
+ from_next = from;
+ to_next = to;
+ return std::codecvt_base::error;
+ }
+
+ virtual bool
+ do_always_noconv() const throw()
+ { return false; }
+};
+
+// libstdc++/13858
+void test01()
+{
+ using namespace std;
+
+ wfilebuf fb;
+ fb.pubimbue(locale(locale::classic(), new Cvt));
+ fb.open("tmp_13858_wchar_t", ios_base::out);
+
+ try
+ {
+ fb.sputc(L'a');
+ fb.sputc(L'b');
+ fb.pubimbue(locale::classic());
+ fb.sputc(L'c');
+ fb.pubsync();
+ fb.close();
+ }
+ catch (std::exception&)
+ {
+ }
+}
+
+int main()
+{
+ test01();
+ return 0;
+}