]>
Commit | Line | Data |
---|---|---|
f63a8495 PC |
1 | // { dg-require-namedlocale "" } |
2 | ||
a945c346 | 3 | // Copyright (C) 2003-2024 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 | ||
27 | class MyFacet : public std::locale::facet | |
28 | { | |
29 | public: | |
30 | static std::locale::id id; | |
31 | }; | |
32 | ||
33 | std::locale::id MyFacet::id; | |
34 | ||
35 | // libstdc++/12438 | |
36 | void test01(int iters) | |
37 | { | |
38 | using namespace std; | |
236c57d1 | 39 | |
155f6fbb PC |
40 | for (int i = 0; i < iters; ++i) |
41 | { | |
42 | try | |
43 | { | |
44 | locale loc1 = locale::classic(); | |
f63a8495 | 45 | locale loc2 = locale(""); |
155f6fbb PC |
46 | VERIFY( !has_facet<MyFacet>(loc2) ); |
47 | ||
fd1a674f | 48 | loc1.combine<MyFacet>(loc2); // { dg-warning "nodiscard" "" { target c++17 } } |
155f6fbb PC |
49 | VERIFY( false ); |
50 | } | |
51 | catch (std::runtime_error&) | |
52 | { | |
53 | } | |
54 | } | |
55 | } | |
56 | ||
57 | int main(int argc, char* argv[]) | |
58 | { | |
59 | // We leaked ~400-500 bytes/iter. | |
9877afe8 PC |
60 | __gnu_test::set_memory_limits(10.0); |
61 | int iters = 30000; | |
155f6fbb PC |
62 | |
63 | if (argc > 1) | |
64 | iters = atoi(argv[1]); | |
65 | if (iters < 1) | |
66 | iters = 1; | |
67 | test01(iters); | |
68 | ||
69 | return 0; | |
70 | } |