+2003-04-17 Benjamin Kosnik <bkoz@redhat.com>
+
+ PR libstdc++/9555
+ * include/bits/ostream.tcc: Catch all exceptions for formatted
+ output, instead of std::exception and derivatives.
+ * include/bits/istream.tcc: Same.
+ * testsuite/27_io/basic_ostream/inserters_arithmetic/char/9555-oa.cc:
+ * testsuite/27_io/basic_ostream/inserters_character/char/9555-oc.cc:
+ * testsuite/27_io/basic_ostream/inserters_other/char/9555-oo.cc:
+ * testsuite/27_io/basic_istream/extractors_arithmetic/char/9555-ia.cc:
+ * testsuite/27_io/basic_istream/extractors_character/char/9555-ic.cc:
+ * testsuite/27_io/basic_istream/extractors_other/char/9555-io.cc:
+ New.
+
2003-04-17 Phil Edwards <pme@gcc.gnu.org>
* include/bits/c++config: Minor cosmetic tweaks.
this->_M_fnumget->get(*this, 0, *this, __err, __n);
this->setstate(__err);
}
- catch(exception& __fail)
+ catch(...)
{
// 27.6.1.2.1 Common requirements.
// Turn this on without causing an ios::failure to be thrown.
#endif
this->setstate(__err);
}
- catch(exception& __fail)
+ catch(...)
{
// 27.6.1.2.1 Common requirements.
// Turn this on without causing an ios::failure to be thrown.
this->_M_fnumget->get(*this, 0, *this, __err, __n);
this->setstate(__err);
}
- catch(exception& __fail)
+ catch(...)
{
// 27.6.1.2.1 Common requirements.
// Turn this on without causing an ios::failure to be thrown.
#endif
this->setstate(__err);
}
- catch(exception& __fail)
+ catch(...)
{
// 27.6.1.2.1 Common requirements.
// Turn this on without causing an ios::failure to be thrown.
this->_M_fnumget->get(*this, 0, *this, __err, __n);
this->setstate(__err);
}
- catch(exception& __fail)
+ catch(...)
{
// 27.6.1.2.1 Common requirements.
// Turn this on without causing an ios::failure to be thrown.
this->_M_fnumget->get(*this, 0, *this, __err, __n);
this->setstate(__err);
}
- catch(exception& __fail)
+ catch(...)
{
// 27.6.1.2.1 Common requirements.
// Turn this on without causing an ios::failure to be thrown.
this->_M_fnumget->get(*this, 0, *this, __err, __n);
this->setstate(__err);
}
- catch(exception& __fail)
+ catch(...)
{
// 27.6.1.2.1 Common requirements.
// Turn this on without causing an ios::failure to be thrown.
this->_M_fnumget->get(*this, 0, *this, __err, __n);
this->setstate(__err);
}
- catch(exception& __fail)
+ catch(...)
{
// 27.6.1.2.1 Common requirements.
// Turn this on without causing an ios::failure to be thrown.
this->_M_fnumget->get(*this, 0, *this, __err, __n);
this->setstate(__err);
}
- catch(exception& __fail)
+ catch(...)
{
// 27.6.1.2.1 Common requirements.
// Turn this on without causing an ios::failure to be thrown.
this->_M_fnumget->get(*this, 0, *this, __err, __n);
this->setstate(__err);
}
- catch(exception& __fail)
+ catch(...)
{
// 27.6.1.2.1 Common requirements.
// Turn this on without causing an ios::failure to be thrown.
this->_M_fnumget->get(*this, 0, *this, __err, __n);
this->setstate(__err);
}
- catch(exception& __fail)
+ catch(...)
{
// 27.6.1.2.1 Common requirements.
// Turn this on without causing an ios::failure to be thrown.
this->_M_fnumget->get(*this, 0, *this, __err, __n);
this->setstate(__err);
}
- catch(exception& __fail)
+ catch(...)
{
// 27.6.1.2.1 Common requirements.
// Turn this on without causing an ios::failure to be thrown.
this->_M_fnumget->get(*this, 0, *this, __err, __n);
this->setstate(__err);
}
- catch(exception& __fail)
+ catch(...)
{
// 27.6.1.2.1 Common requirements.
// Turn this on without causing an ios::failure to be thrown.
if (!__sbout || !__xtrct)
this->setstate(ios_base::failbit);
}
- catch(exception& __fail)
+ catch(...)
{
// 27.6.2.5.1 Common requirements.
// Turn this on without causing an ios::failure to be thrown.
else
this->setstate(ios_base::eofbit | ios_base::failbit);
}
- catch(exception& __fail)
+ catch(...)
{
// 27.6.1.3 paragraph 1
// Turn this on without causing an ios::failure to be thrown.
else
this->setstate(ios_base::eofbit | ios_base::failbit);
}
- catch(exception& __fail)
+ catch(...)
{
// 27.6.1.3 paragraph 1
// Turn this on without causing an ios::failure to be thrown.
if (traits_type::eq_int_type(__c, __eof))
this->setstate(ios_base::eofbit);
}
- catch(exception& __fail)
+ catch(...)
{
// 27.6.1.3 paragraph 1
// Turn this on without causing an ios::failure to be thrown.
if (traits_type::eq_int_type(__c, __eof))
this->setstate(ios_base::eofbit);
}
- catch(exception& __fail)
+ catch(...)
{
// 27.6.1.3 paragraph 1
// Turn this on without causing an ios::failure to be thrown.
this->setstate(ios_base::failbit);
}
}
- catch(exception& __fail)
+ catch(...)
{
// 27.6.1.3 paragraph 1
// Turn this on without causing an ios::failure to be thrown.
if (traits_type::eq_int_type(__c, __eof))
this->setstate(ios_base::eofbit);
}
- catch(exception& __fail)
+ catch(...)
{
// 27.6.1.3 paragraph 1
// Turn this on without causing an ios::failure to be thrown.
{
try
{ __c = this->rdbuf()->sgetc(); }
- catch(exception& __fail)
+ catch(...)
{
// 27.6.1.3 paragraph 1
// Turn this on without causing an ios::failure to be thrown.
if (_M_gcount != __n)
this->setstate(ios_base::eofbit | ios_base::failbit);
}
- catch(exception& __fail)
+ catch(...)
{
// 27.6.1.3 paragraph 1
// Turn this on without causing an ios::failure to be thrown.
else
this->setstate(ios_base::eofbit);
}
- catch(exception& __fail)
+ catch(...)
{
// 27.6.1.3 paragraph 1
// Turn this on without causing an ios::failure to be thrown.
|| traits_type::eq_int_type(__sb->sputbackc(__c), __eof))
this->setstate(ios_base::badbit);
}
- catch(exception& __fail)
+ catch(...)
{
// 27.6.1.3 paragraph 1
// Turn this on without causing an ios::failure to be thrown.
|| traits_type::eq_int_type(__sb->sungetc(), __eof))
this->setstate(ios_base::badbit);
}
- catch(exception& __fail)
+ catch(...)
{
// 27.6.1.3 paragraph 1
// Turn this on without causing an ios::failure to be thrown.
__ret = 0;
}
}
- catch(exception& __fail)
+ catch(...)
{
// 27.6.1.3 paragraph 1
// Turn this on without causing an ios::failure to be thrown.
{
try
{ __in.get(__c); }
- catch(exception& __fail)
+ catch(...)
{
// 27.6.1.2.1 Common requirements.
// Turn this on without causing an ios::failure to be thrown.
#endif
__in.width(0);
}
- catch(exception& __fail)
+ catch(...)
{
// 27.6.1.2.1 Common requirements.
// Turn this on without causing an ios::failure to be thrown.
{
try
{ __pf(*this); }
- catch(exception& __fail)
+ catch(...)
{
// 27.6.2.5.1 Common requirements.
// Turn this on without causing an ios::failure to be thrown.
{
try
{ __pf(*this); }
- catch(exception& __fail)
+ catch(...)
{
// 27.6.2.5.1 Common requirements.
// Turn this on without causing an ios::failure to be thrown.
{
try
{ __pf(*this); }
- catch(exception& __fail)
+ catch(...)
{
// 27.6.2.5.1 Common requirements.
// Turn this on without causing an ios::failure to be thrown.
if (!__copy_streambufs(*this, __sbin, this->rdbuf()))
this->setstate(ios_base::failbit);
}
- catch(exception& __fail)
+ catch(...)
{
// 27.6.2.5.1 Common requirements.
// Turn this on without causing an ios::failure to be thrown.
this->fill(), __n).failed())
this->setstate(ios_base::badbit);
}
- catch(exception& __fail)
+ catch(...)
{
// 27.6.1.2.1 Common requirements.
// Turn this on without causing an ios::failure to be thrown.
this->setstate(ios_base::badbit);
}
}
- catch(exception& __fail)
+ catch(...)
{
// 27.6.1.2.1 Common requirements.
// Turn this on without causing an ios::failure to be thrown.
this->fill(), __n).failed())
this->setstate(ios_base::badbit);
}
- catch(exception& __fail)
+ catch(...)
{
// 27.6.1.2.1 Common requirements.
// Turn this on without causing an ios::failure to be thrown.
this->setstate(ios_base::badbit);
}
}
- catch(exception& __fail)
+ catch(...)
{
// 27.6.1.2.1 Common requirements.
// Turn this on without causing an ios::failure to be thrown.
this->fill(), __n).failed())
this->setstate(ios_base::badbit);
}
- catch(exception& __fail)
+ catch(...)
{
// 27.6.1.2.1 Common requirements.
// Turn this on without causing an ios::failure to be thrown.
this->fill(), __n).failed())
this->setstate(ios_base::badbit);
}
- catch(exception& __fail)
+ catch(...)
{
// 27.6.1.2.1 Common requirements.
// Turn this on without causing an ios::failure to be thrown.
this->fill(), __n).failed())
this->setstate(ios_base::badbit);
}
- catch(exception& __fail)
+ catch(...)
{
// 27.6.1.2.1 Common requirements.
// Turn this on without causing an ios::failure to be thrown.
this->fill(), __n).failed())
this->setstate(ios_base::badbit);
}
- catch(exception& __fail)
+ catch(...)
{
// 27.6.1.2.1 Common requirements.
// Turn this on without causing an ios::failure to be thrown.
__out._M_write(__pads, __len);
__out.width(0);
}
- catch(exception& __fail)
+ catch(...)
{
// 27.6.1.2.1 Common requirements.
// Turn this on without causing an ios::failure to be thrown.
__out._M_write(__pads, __len);
__out.width(0);
}
- catch(exception& __fail)
+ catch(...)
{
// 27.6.1.2.1 Common requirements.
// Turn this on without causing an ios::failure to be thrown.
__out._M_write(__s, __len);
__out.width(0);
}
- catch(exception& __fail)
+ catch(...)
{
// 27.6.1.2.1 Common requirements.
// Turn this on without causing an ios::failure to be thrown.
__out._M_write(__str, __len);
__out.width(0);
}
- catch(exception& __fail)
+ catch(...)
{
// 27.6.1.2.1 Common requirements.
// Turn this on without causing an ios::failure to be thrown.
__out._M_write(__s, __len);
__out.width(0);
}
- catch(exception& __fail)
+ catch(...)
{
// 27.6.1.2.1 Common requirements.
// Turn this on without causing an ios::failure to be thrown.
--- /dev/null
+// 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.
+
+// As a special exception, you may use this file as part of a free software
+// library without restriction. Specifically, if other files instantiate
+// templates or use macros or inline functions from this file, or you compile
+// this file and link it with other files to produce an executable, this
+// file does not by itself cause the resulting executable to be covered by
+// the GNU General Public License. This exception does not however
+// invalidate any other reasons why the executable file might be covered by
+// the GNU General Public License.
+
+#include <istream>
+#include <streambuf>
+#include <testsuite_hooks.h>
+
+struct buf: std::streambuf
+{
+ virtual int_type overflow(int_type)
+ { throw 0; }
+};
+
+template<typename T>
+void testthrow(T arg)
+{
+ bool test = true;
+ buf b;
+ std::istream is(&b);
+ is.exceptions(std::ios::badbit);
+
+ try
+ {
+ is >> arg;
+ }
+ catch(int)
+ {
+ // Expected return is zero.
+ VERIFY( is.bad() );
+ }
+ catch(...)
+ {
+ VERIFY( false );
+ }
+}
+
+int main()
+{
+ bool b = true;
+ short s = -4;
+ unsigned short us = 4;
+ int i = -45;
+ unsigned int ui = 45;
+ long l = -456;
+ unsigned long ul = 456;
+ float f = 3.4;
+ double d = 3.45;
+ long double ld = 3.456;
+
+ testthrow(b);
+ testthrow(s);
+ testthrow(us);
+ testthrow(i);
+ testthrow(ui);
+ testthrow(l);
+ testthrow(ul);
+ testthrow(f);
+ testthrow(d);
+ testthrow(ld);
+
+ return 0;
+}
--- /dev/null
+// 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.
+
+// As a special exception, you may use this file as part of a free software
+// library without restriction. Specifically, if other files instantiate
+// templates or use macros or inline functions from this file, or you compile
+// this file and link it with other files to produce an executable, this
+// file does not by itself cause the resulting executable to be covered by
+// the GNU General Public License. This exception does not however
+// invalidate any other reasons why the executable file might be covered by
+// the GNU General Public License.
+
+#include <istream>
+#include <streambuf>
+//#include <testsuite_hooks.h>
+#define VERIFY(x) x
+
+struct buf: std::streambuf
+{
+ virtual int_type overflow(int_type)
+ { throw 0; }
+};
+
+template<typename T>
+void testthrow(T arg)
+{
+ bool test = true;
+ buf b;
+ std::istream is(&b);
+ is.exceptions(std::ios::badbit);
+
+ try
+ {
+ is >> arg;
+ }
+ catch(int)
+ {
+ // Expected return is zero.
+ VERIFY( is.bad() );
+ }
+ catch(...)
+ {
+ VERIFY( false );
+ }
+}
+
+int main()
+{
+ char c = 'a';
+ unsigned char uc = 'a';
+ signed char sc = 'a';
+ char* cp = &c;
+ signed char* scp = ≻
+ unsigned char* ucp = &uc;
+
+ testthrow(c);
+ testthrow(uc);
+ testthrow(sc);
+ testthrow(cp);
+ testthrow(scp);
+ testthrow(ucp);
+
+ return 0;
+}
--- /dev/null
+// 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.
+
+// As a special exception, you may use this file as part of a free software
+// library without restriction. Specifically, if other files instantiate
+// templates or use macros or inline functions from this file, or you compile
+// this file and link it with other files to produce an executable, this
+// file does not by itself cause the resulting executable to be covered by
+// the GNU General Public License. This exception does not however
+// invalidate any other reasons why the executable file might be covered by
+// the GNU General Public License.
+
+#include <istream>
+#include <streambuf>
+#include <testsuite_hooks.h>
+
+struct buf: std::streambuf
+{
+ virtual int_type overflow(int_type)
+ { throw 0; }
+};
+
+template<typename T>
+void testthrow(T arg)
+{
+ bool test = true;
+ buf b;
+ std::istream is(&b);
+ is.exceptions(std::ios::badbit);
+
+ try
+ {
+ is >> arg;
+ }
+ catch(int)
+ {
+ // Expected return is zero.
+ VERIFY( is.bad() );
+ }
+ catch(...)
+ {
+ VERIFY( false );
+ }
+}
+
+int main()
+{
+ buf b;
+
+ testthrow(&b);
+
+ return 0;
+}
--- /dev/null
+// 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.
+
+// As a special exception, you may use this file as part of a free software
+// library without restriction. Specifically, if other files instantiate
+// templates or use macros or inline functions from this file, or you compile
+// this file and link it with other files to produce an executable, this
+// file does not by itself cause the resulting executable to be covered by
+// the GNU General Public License. This exception does not however
+// invalidate any other reasons why the executable file might be covered by
+// the GNU General Public License.
+
+#include <ostream>
+#include <streambuf>
+#include <testsuite_hooks.h>
+
+struct buf: std::streambuf
+{
+ virtual int_type overflow(int_type)
+ { throw 0; }
+};
+
+template<typename T>
+void testthrow(T arg)
+{
+ bool test = true;
+ buf b;
+ std::ostream os(&b);
+ os.exceptions(std::ios::badbit);
+
+ try
+ {
+ os << arg;
+ }
+ catch(int)
+ {
+ // Expected return is zero.
+ VERIFY( os.bad() );
+ }
+ catch(...)
+ {
+ VERIFY( false );
+ }
+}
+
+int main()
+{
+ bool b = true;
+ short s = -4;
+ unsigned short us = 4;
+ int i = -45;
+ unsigned int ui = 45;
+ long l = -456;
+ unsigned long ul = 456;
+ float f = 3.4;
+ double d = 3.45;
+ long double ld = 3.456;
+
+ testthrow(b);
+ testthrow(s);
+ testthrow(us);
+ testthrow(i);
+ testthrow(ui);
+ testthrow(l);
+ testthrow(ul);
+ testthrow(f);
+ testthrow(d);
+ testthrow(ld);
+
+ return 0;
+}
--- /dev/null
+// 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.
+
+// As a special exception, you may use this file as part of a free software
+// library without restriction. Specifically, if other files instantiate
+// templates or use macros or inline functions from this file, or you compile
+// this file and link it with other files to produce an executable, this
+// file does not by itself cause the resulting executable to be covered by
+// the GNU General Public License. This exception does not however
+// invalidate any other reasons why the executable file might be covered by
+// the GNU General Public License.
+
+#include <ostream>
+#include <streambuf>
+#include <testsuite_hooks.h>
+
+struct buf: std::streambuf
+{
+ virtual int_type overflow(int_type)
+ { throw 0; }
+};
+
+template<typename T>
+void testthrow(T arg)
+{
+ bool test = true;
+ buf b;
+ std::ostream os(&b);
+ os.exceptions(std::ios::badbit);
+
+ try
+ {
+ os << arg;
+ }
+ catch(int)
+ {
+ // Expected return is zero.
+ VERIFY( os.bad() );
+ }
+ catch(...)
+ {
+ VERIFY( false );
+ }
+}
+
+int main()
+{
+ char c = 'a';
+ unsigned char uc = 'a';
+ signed char sc = 'a';
+ const char* ccp = "governor ann richards";
+ const signed char* cscp = reinterpret_cast<const signed char*>(ccp);
+ const unsigned char* cucp = reinterpret_cast<const unsigned char*>(ccp);
+
+ testthrow(c);
+ testthrow(uc);
+ testthrow(sc);
+ testthrow(ccp);
+ testthrow(cscp);
+ testthrow(cucp);
+
+ return 0;
+}
--- /dev/null
+// 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.
+
+// As a special exception, you may use this file as part of a free software
+// library without restriction. Specifically, if other files instantiate
+// templates or use macros or inline functions from this file, or you compile
+// this file and link it with other files to produce an executable, this
+// file does not by itself cause the resulting executable to be covered by
+// the GNU General Public License. This exception does not however
+// invalidate any other reasons why the executable file might be covered by
+// the GNU General Public License.
+
+#include <ostream>
+#include <streambuf>
+#include <testsuite_hooks.h>
+
+struct buf: std::streambuf
+{
+ virtual int_type overflow(int_type)
+ { throw 0; }
+};
+
+template<typename T>
+void testthrow(T arg)
+{
+ bool test = true;
+ buf b;
+ std::ostream os(&b);
+ os.exceptions(std::ios::badbit);
+
+ try
+ {
+ os << arg;
+ }
+ catch(int)
+ {
+ // Expected return is zero.
+ VERIFY( os.bad() );
+ }
+ catch(...)
+ {
+ VERIFY( false );
+ }
+}
+
+int main()
+{
+ buf b;
+
+ testthrow(&b);
+
+ return 0;
+}