aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaolo Carlini <pcarlini@suse.de>2008-02-10 15:48:10 +0000
committerPaolo Carlini <paolo@gcc.gnu.org>2008-02-10 15:48:10 +0000
commitb3aaa61791797d959afe248f34cbfc5e7c5cc5b2 (patch)
tree077ed2a47177325057f56a1bd722271cc32c6e5e
parent3d39d4151c97209560943f8342070ca7be64b72d (diff)
downloadgcc-b3aaa61791797d959afe248f34cbfc5e7c5cc5b2.zip
gcc-b3aaa61791797d959afe248f34cbfc5e7c5cc5b2.tar.gz
gcc-b3aaa61791797d959afe248f34cbfc5e7c5cc5b2.tar.bz2
re PR libstdc++/16251 (bogus default constructor for std::basic_iostream)
2008-02-10 Paolo Carlini <pcarlini@suse.de> PR libstdc++/16251 * include/std/istream (basic_istream<>::basic_istream()): Call this->init(). (basic_iostream<>::basic_iostream(basic_streambuf<>*)): Don't do it here, per 27.6.1.5.1/1. * include/std/ostream (basic_ostream<>::basic_ostream()): Call this->init(). * testsuite/27_io/basic_iostream/cons/16251.C: New. * testsuite/27_io/basic_iostream/cons/2020.cc: Minor tweaks. From-SVN: r132214
-rw-r--r--libstdc++-v3/ChangeLog13
-rw-r--r--libstdc++-v3/include/std/istream24
-rw-r--r--libstdc++-v3/include/std/ostream6
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_iostream/cons/16251.C42
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_iostream/cons/2020.cc6
5 files changed, 73 insertions, 18 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog
index 936c0b0..b3442e6 100644
--- a/libstdc++-v3/ChangeLog
+++ b/libstdc++-v3/ChangeLog
@@ -1,3 +1,16 @@
+2008-02-10 Paolo Carlini <pcarlini@suse.de>
+
+ PR libstdc++/16251
+ * include/std/istream (basic_istream<>::basic_istream()): Call
+ this->init().
+ (basic_iostream<>::basic_iostream(basic_streambuf<>*)): Don't
+ do it here, per 27.6.1.5.1/1.
+ * include/std/ostream (basic_ostream<>::basic_ostream()): Call
+ this->init().
+ * testsuite/27_io/basic_iostream/cons/16251.C: New.
+
+ * testsuite/27_io/basic_iostream/cons/2020.cc: Minor tweaks.
+
2008-01-31 Ralf Wildenhues <Ralf.Wildenhues@gmx.de>
* include/backward/auto_ptr.h: Fix comment typos.
diff --git a/libstdc++-v3/include/std/istream b/libstdc++-v3/include/std/istream
index 331e643..caf670b 100644
--- a/libstdc++-v3/include/std/istream
+++ b/libstdc++-v3/include/std/istream
@@ -1,7 +1,7 @@
// Input streams -*- C++ -*-
// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
-// 2006, 2007
+// 2006, 2007, 2008
// Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
@@ -91,8 +91,9 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
* derived classes' initialization lists, which pass a pointer to
* their own stream buffer.
*/
- explicit
- basic_istream(__streambuf_type* __sb): _M_gcount(streamsize(0))
+ explicit
+ basic_istream(__streambuf_type* __sb)
+ : _M_gcount(streamsize(0))
{ this->init(__sb); }
/**
@@ -581,8 +582,9 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
//@}
protected:
- explicit
- basic_istream(): _M_gcount(streamsize(0)) { }
+ basic_istream()
+ : _M_gcount(streamsize(0))
+ { this->init(0); }
template<typename _ValueT>
__istream_type&
@@ -665,7 +667,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
* If the stream state is still good, then the sentry state becomes
* true ("okay").
*/
- explicit
+ explicit
sentry(basic_istream<_CharT, _Traits>& __is, bool __noskipws = false);
/**
@@ -788,10 +790,9 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
* Both of the parent classes are initialized with the same
* streambuf pointer passed to this constructor.
*/
- explicit
+ explicit
basic_iostream(basic_streambuf<_CharT, _Traits>* __sb)
- : __istream_type(), __ostream_type()
- { this->init(__sb); }
+ : __istream_type(__sb), __ostream_type(__sb) { }
/**
* @brief Destructor does nothing.
@@ -800,9 +801,8 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
~basic_iostream() { }
protected:
- explicit
- basic_iostream() : __istream_type(), __ostream_type()
- { }
+ basic_iostream()
+ : __istream_type(), __ostream_type() { }
};
// [27.6.1.4] standard basic_istream manipulators
diff --git a/libstdc++-v3/include/std/ostream b/libstdc++-v3/include/std/ostream
index c426475..ffbb0e1 100644
--- a/libstdc++-v3/include/std/ostream
+++ b/libstdc++-v3/include/std/ostream
@@ -1,7 +1,7 @@
// Output streams -*- C++ -*-
// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
-// 2006, 2007
+// 2006, 2007, 2008
// Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
@@ -366,8 +366,8 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
seekp(off_type, ios_base::seekdir);
protected:
- explicit
- basic_ostream() { }
+ basic_ostream()
+ { this->init(0); }
template<typename _ValueT>
__ostream_type&
diff --git a/libstdc++-v3/testsuite/27_io/basic_iostream/cons/16251.C b/libstdc++-v3/testsuite/27_io/basic_iostream/cons/16251.C
new file mode 100644
index 0000000..0167d1d
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_iostream/cons/16251.C
@@ -0,0 +1,42 @@
+// Copyright (C) 2008 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.6.1.5 - Template class basic_iostream
+
+#include <iostream>
+
+class mystream
+: public std::iostream
+{
+public:
+ mystream () { };
+};
+
+// libstdc++/16251
+void test01()
+{
+ mystream x;
+ x.rdbuf(std::cout.rdbuf());
+ x << std::endl;
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_iostream/cons/2020.cc b/libstdc++-v3/testsuite/27_io/basic_iostream/cons/2020.cc
index e0af3eb..014ab71 100644
--- a/libstdc++-v3/testsuite/27_io/basic_iostream/cons/2020.cc
+++ b/libstdc++-v3/testsuite/27_io/basic_iostream/cons/2020.cc
@@ -1,6 +1,7 @@
// 1999-01-17 bkoz test functionality of basic_filebuf for char_type == char
-// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005
+// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
+// 2006, 2007, 2008
// Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
@@ -19,8 +20,7 @@
// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
// USA.
-// 27.8.1.1 - Template class basic_filebuf
-// NB: This file is for testing basic_filebuf with NO OTHER INCLUDES.
+// 27.6.1.5 - Template class basic_iostream
#include <iostream>
#include <testsuite_hooks.h>