1255332Scy// Copyright (C) 2004, 2009 Free Software Foundation, Inc. 2145516Sdarrenr// 3255332Scy// This file is part of the GNU ISO C++ Library. This library is free 4145516Sdarrenr// software; you can redistribute it and/or modify it under the 5145516Sdarrenr// terms of the GNU General Public License as published by the 6145516Sdarrenr// Free Software Foundation; either version 3, or (at your option) 7145516Sdarrenr// any later version. 8145516Sdarrenr 9145516Sdarrenr// This library is distributed in the hope that it will be useful, 10145516Sdarrenr// but WITHOUT ANY WARRANTY; without even the implied warranty of 11145516Sdarrenr// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12145516Sdarrenr// GNU General Public License for more details. 13145516Sdarrenr 14145516Sdarrenr// You should have received a copy of the GNU General Public License along 15145516Sdarrenr// with this library; see the file COPYING3. If not see 16145516Sdarrenr// <http://www.gnu.org/licenses/>. 17145516Sdarrenr 18145516Sdarrenr 19145516Sdarrenr#include <istream> 20145516Sdarrenr#include <streambuf> 21145516Sdarrenr#include <testsuite_hooks.h> 22145516Sdarrenr 23145516Sdarrenrstruct buf: std::wstreambuf 24145516Sdarrenr{ 25145516Sdarrenr virtual int_type overflow(int_type) 26145516Sdarrenr { throw 0; } 27145516Sdarrenr}; 28255332Scy 29145516Sdarrenrtemplate<typename T> 30255332Scyvoid testthrow(T arg) 31145516Sdarrenr{ 32145516Sdarrenr bool test __attribute__((unused)) = true; 33145516Sdarrenr buf b; 34145516Sdarrenr std::wistream is(&b); 35145516Sdarrenr is.exceptions(std::wios::badbit); 36145516Sdarrenr 37145516Sdarrenr try 38145516Sdarrenr { 39145516Sdarrenr is >> arg; 40145516Sdarrenr } 41255332Scy catch(int) 42255332Scy { 43145516Sdarrenr // Expected return is zero. 44145516Sdarrenr VERIFY( is.bad() ); 45145516Sdarrenr } 46145516Sdarrenr catch(...) 47145516Sdarrenr { 48145516Sdarrenr test = false; 49255332Scy VERIFY( test ); 50255332Scy } 51145516Sdarrenr} 52145516Sdarrenr 53145516Sdarrenrint main() 54145516Sdarrenr{ 55145516Sdarrenr wchar_t c = L'a'; 56255332Scy wchar_t* cp = &c; 57145516Sdarrenr 58145516Sdarrenr testthrow(c); 59255332Scy testthrow(cp); 60145516Sdarrenr 61145516Sdarrenr return 0; 62145516Sdarrenr} 63255332Scy