]>
git.ipfire.org Git - thirdparty/gcc.git/blob - libstdc++-v3/testsuite/22_locale/locale/cons/12352.cc
1 // { dg-require-namedlocale "" }
2 // { dg-require-namedlocale "en_US.ISO8859-1" }
4 // Copyright (C) 2003-2022 Free Software Foundation, Inc.
6 // This file is part of the GNU ISO C++ Library. This library is free
7 // software; you can redistribute it and/or modify it under the
8 // terms of the GNU General Public License as published by the
9 // Free Software Foundation; either version 3, or (at your option)
12 // This library is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 // GNU General Public License for more details.
17 // You should have received a copy of the GNU General Public License along
18 // with this library; see the file COPYING3. If not see
19 // <http://www.gnu.org/licenses/>.
21 // 22.1.1.2 locale constructors and destructors [lib.locale.cons]
27 #include <testsuite_hooks.h>
29 int times_to_fail
= 0;
31 void* allocate(std::size_t n
)
36 void* ret
= std::malloc(n
? n
: 1);
38 std::memset(ret
, 0xbc, n
);
42 void deallocate(void* p
)
48 void* operator new(std::size_t n
) THROW (std::bad_alloc
)
50 void* ret
= allocate(n
);
52 throw std::bad_alloc();
56 void* operator new[](std::size_t n
) THROW (std::bad_alloc
)
58 void* ret
= allocate(n
);
60 throw std::bad_alloc();
64 void operator delete(void* p
) throw()
69 void operator delete[](void* p
) throw()
74 #if __cpp_sized_deallocation
75 void operator delete(void* p
, std::size_t) throw()
80 void operator delete[](void* p
, std::size_t) throw()
86 void* operator new(std::size_t n
, const std::nothrow_t
&) throw()
91 void* operator new[](std::size_t n
, const std::nothrow_t
&) throw()
96 void operator delete(void* p
, const std::nothrow_t
&) throw()
101 void operator delete[](void* p
, const std::nothrow_t
&) throw()
107 void test01(int iters
)
109 for (int j
= 0; j
< iters
; ++j
)
111 for (int i
= 0; i
< 100; ++i
)
116 std::locale loc1
= std::locale("");
117 std::locale
loc2(loc1
, std::locale::classic(),
118 std::locale::numeric
);
119 std::locale loc3
= std::locale(ISO_8859(1,en_US
));
120 std::locale
loc4(loc3
, std::locale::classic(),
121 std::locale::numeric
);
123 catch (std::exception
&)
130 int main(int argc
, char* argv
[])
134 iters
= std::atoi(argv
[1]);