aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaolo Carlini <pcarlini@unitus.it>2003-02-11 11:43:49 +0100
committerPaolo Carlini <paolo@gcc.gnu.org>2003-02-11 10:43:49 +0000
commitdfc7d8996515160bc008f5e4c942f3fdd4c96545 (patch)
treeebe902306e4a15ad31f2a8f37a87098265fa8a10
parentda61d02231ca20ebc788ad86655952cff1781171 (diff)
downloadgcc-dfc7d8996515160bc008f5e4c942f3fdd4c96545.zip
gcc-dfc7d8996515160bc008f5e4c942f3fdd4c96545.tar.gz
gcc-dfc7d8996515160bc008f5e4c942f3fdd4c96545.tar.bz2
re PR libstdc++/9320 (Incorrect usage of traits_type::int_type in stdio_filebuf)
2003-02-11 Paolo Carlini <pcarlini@unitus.it> PR libstdc++/9320 * include/ext/stdio_filebuf.h (stdio_filebuf(int, std::ios_base::openmode, bool, int_type), stdio_filebuf(std::__c_file*, std::ios_base::openmode, int_type)): Change to take a __size parameter of type size_t, not of type (template parameter dependent) int_type. * src/ios.cc (ios_base::Init::_S_ios_create): Change type of size vars to size_t. * testsuite/ext/stdio_filebuf.cc: Add. From-SVN: r62691
-rw-r--r--libstdc++-v3/ChangeLog12
-rw-r--r--libstdc++-v3/include/ext/stdio_filebuf.h9
-rw-r--r--libstdc++-v3/src/ios.cc7
-rw-r--r--libstdc++-v3/testsuite/ext/stdio_filebuf.cc36
4 files changed, 57 insertions, 7 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog
index 9816498..e02707b 100644
--- a/libstdc++-v3/ChangeLog
+++ b/libstdc++-v3/ChangeLog
@@ -1,4 +1,16 @@
2003-02-11 Paolo Carlini <pcarlini@unitus.it>
+
+ PR libstdc++/9320
+ * include/ext/stdio_filebuf.h
+ (stdio_filebuf(int, std::ios_base::openmode, bool, int_type),
+ stdio_filebuf(std::__c_file*, std::ios_base::openmode, int_type)):
+ Change to take a __size parameter of type size_t, not
+ of type (template parameter dependent) int_type.
+ * src/ios.cc (ios_base::Init::_S_ios_create): Change type of
+ size vars to size_t.
+ * testsuite/ext/stdio_filebuf.cc: Add.
+
+2003-02-11 Paolo Carlini <pcarlini@unitus.it>
Petur Runolfsson <peturr02@ru.is>
PR libstdc++/9318
diff --git a/libstdc++-v3/include/ext/stdio_filebuf.h b/libstdc++-v3/include/ext/stdio_filebuf.h
index 1fb40be..c412564 100644
--- a/libstdc++-v3/include/ext/stdio_filebuf.h
+++ b/libstdc++-v3/include/ext/stdio_filebuf.h
@@ -58,6 +58,7 @@ namespace __gnu_cxx
typedef typename traits_type::int_type int_type;
typedef typename traits_type::pos_type pos_type;
typedef typename traits_type::off_type off_type;
+ typedef std::size_t size_t;
protected:
// Stack-based buffer for unbuffered input.
@@ -75,7 +76,7 @@ namespace __gnu_cxx
* file will be closed when the stdio_filebuf is closed/destroyed.
*/
stdio_filebuf(int __fd, std::ios_base::openmode __mode, bool __del,
- int_type __size);
+ size_t __size);
/**
* @param f An open @c FILE*.
@@ -88,7 +89,7 @@ namespace __gnu_cxx
* stdio_filebuf is closed/destroyed.
*/
stdio_filebuf(std::__c_file* __f, std::ios_base::openmode __mode,
- int_type __size = static_cast<int_type>(BUFSIZ));
+ size_t __size = static_cast<size_t>(BUFSIZ));
/**
* Possibly closes the external data stream, in the case of the file
@@ -117,7 +118,7 @@ namespace __gnu_cxx
template<typename _CharT, typename _Traits>
stdio_filebuf<_CharT, _Traits>::
stdio_filebuf(int __fd, std::ios_base::openmode __mode, bool __del,
- int_type __size)
+ size_t __size)
{
this->_M_file.sys_open(__fd, __mode, __del);
if (this->is_open())
@@ -142,7 +143,7 @@ namespace __gnu_cxx
template<typename _CharT, typename _Traits>
stdio_filebuf<_CharT, _Traits>::
stdio_filebuf(std::__c_file* __f, std::ios_base::openmode __mode,
- int_type __size)
+ size_t __size)
{
this->_M_file.sys_open(__f, __mode);
if (this->is_open())
diff --git a/libstdc++-v3/src/ios.cc b/libstdc++-v3/src/ios.cc
index 9f4c718..75fdee1 100644
--- a/libstdc++-v3/src/ios.cc
+++ b/libstdc++-v3/src/ios.cc
@@ -159,11 +159,12 @@ namespace std
void
ios_base::Init::_S_ios_create(bool __sync)
{
- int __out_size = __sync ? 0 : static_cast<int>(BUFSIZ);
+ size_t __out_size = __sync ? 0 : static_cast<size_t>(BUFSIZ);
#ifdef _GLIBCPP_HAVE_ISATTY
- int __in_size = (__sync || isatty (0)) ? 1 : static_cast<int>(BUFSIZ);
+ size_t __in_size =
+ (__sync || isatty (0)) ? 1 : static_cast<size_t>(BUFSIZ);
#else
- int __in_size = 1;
+ size_t __in_size = 1;
#endif
// NB: The file globals.cc creates the four standard files
diff --git a/libstdc++-v3/testsuite/ext/stdio_filebuf.cc b/libstdc++-v3/testsuite/ext/stdio_filebuf.cc
new file mode 100644
index 0000000..ec34815
--- /dev/null
+++ b/libstdc++-v3/testsuite/ext/stdio_filebuf.cc
@@ -0,0 +1,36 @@
+// 2003-02-11 Paolo Carlini <pcarlini@unitus.it>
+
+// Copyright (C) 2003 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, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+// USA.
+
+// stdio_filebuf.h
+
+#include <ext/stdio_filebuf.h>
+#include <testsuite_hooks.h>
+
+// { dg-do compile }
+
+// libstdc++/9320
+namespace test
+{
+ using namespace std;
+ using __gnu_cxx_test::pod_char;
+ typedef short type_t;
+ template class __gnu_cxx::stdio_filebuf<type_t, char_traits<type_t> >;
+ template class __gnu_cxx::stdio_filebuf<pod_char, char_traits<pod_char> >;
+} // test