]> git.ipfire.org Git - thirdparty/gcc.git/blame - libstdc++-v3/testsuite/22_locale/locale/cons/12438.cc
Update copyright years in libstdc++-v3/
[thirdparty/gcc.git] / libstdc++-v3 / testsuite / 22_locale / locale / cons / 12438.cc
CommitLineData
f63a8495
PC
1// { dg-require-namedlocale "" }
2
aa118a03 3// Copyright (C) 2003-2014 Free Software Foundation, Inc.
155f6fbb
PC
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
748086b7 8// Free Software Foundation; either version 3, or (at your option)
155f6fbb
PC
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
748086b7
JJ
17// with this library; see the file COPYING3. If not see
18// <http://www.gnu.org/licenses/>.
155f6fbb
PC
19
20// 22.1.1.2 locale constructors and destructors [lib.locale.cons]
21
22#include <locale>
23#include <stdexcept>
24#include <cstdlib>
25#include <testsuite_hooks.h>
26
27class MyFacet : public std::locale::facet
28{
29public:
30 static std::locale::id id;
31};
32
33std::locale::id MyFacet::id;
34
35// libstdc++/12438
36void test01(int iters)
37{
38 using namespace std;
39 bool test __attribute__((unused)) = true;
40
41 for (int i = 0; i < iters; ++i)
42 {
43 try
44 {
45 locale loc1 = locale::classic();
f63a8495 46 locale loc2 = locale("");
155f6fbb
PC
47 VERIFY( !has_facet<MyFacet>(loc2) );
48
49 loc1.combine<MyFacet>(loc2);
50 VERIFY( false );
51 }
52 catch (std::runtime_error&)
53 {
54 }
55 }
56}
57
58int main(int argc, char* argv[])
59{
60 // We leaked ~400-500 bytes/iter.
9877afe8
PC
61 __gnu_test::set_memory_limits(10.0);
62 int iters = 30000;
155f6fbb
PC
63
64 if (argc > 1)
65 iters = atoi(argv[1]);
66 if (iters < 1)
67 iters = 1;
68 test01(iters);
69
70 return 0;
71}