]> git.ipfire.org Git - thirdparty/gcc.git/blame - libstdc++-v3/testsuite/22_locale/facet/25421.cc
re PR libstdc++/25421 (catching exception from codecvt_byname() segfaults)
[thirdparty/gcc.git] / libstdc++-v3 / testsuite / 22_locale / facet / 25421.cc
CommitLineData
cd6dba21
PC
1// 2005-12-15 Paolo Carlini <pcarlini@suse.de>
2
3// Copyright (C) 2005 Free Software Foundation
4//
5// This file is part of the GNU ISO C++ Library. This library is free
6// software; you can redistribute it and/or modify it under the
7// terms of the GNU General Public License as published by the
8// Free Software Foundation; either version 2, or (at your option)
9// any later version.
10
11// This library is distributed in the hope that it will be useful,
12// but WITHOUT ANY WARRANTY; without even the implied warranty of
13// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14// GNU General Public License for more details.
15
16// You should have received a copy of the GNU General Public License along
17// with this library; see the file COPYING. If not, write to the Free
18// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
19// USA.
20
21// 22.1.1.1.2 - class locale::facet [lib.locale.facet]
22
23#include <stdexcept>
24#include <locale>
25#include <testsuite_hooks.h>
26
27// libstdc++/25421
28void test01()
29{
30 bool test __attribute__((unused)) = true;
31 using namespace std;
32
33 try
34 {
35 new codecvt_byname<char, char, mbstate_t>("invalid-loc");
36 new collate_byname<char>("invalid-loc");
37 new ctype_byname<char>("invalid-loc");
38 new messages_byname<char>("invalid-loc");
39 new moneypunct_byname<char, true>("invalid-loc");
40 new numpunct_byname<char>("invalid-loc");
41
42#ifdef _GLIBCXX_USE_WCHAR_T
43 new codecvt_byname<wchar_t, char, mbstate_t>("invalid-loc");
44 new collate_byname<wchar_t>("invalid-loc");
45 new ctype_byname<wchar_t>("invalid-loc");
46 new messages_byname<wchar_t>("invalid-loc");
47 new moneypunct_byname<wchar_t, true>("invalid-loc");
48 new numpunct_byname<wchar_t>("invalid-loc");
49#endif
50 }
51 catch(const std::runtime_error&)
52 {
53 // named locale not valid
54 VERIFY( true );
55 }
56 catch(...)
57 {
58 // some other error
59 VERIFY( false );
60 }
61}
62
63int main()
64{
65 test01();
66 return 0;
67}