OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [tags/] [gnu-src/] [gcc-4.5.1/] [gcc-4.5.1-or32-1.0rc4/] [libstdc++-v3/] [testsuite/] [22_locale/] [locale/] [cons/] [12352.cc] - Blame information for rev 519

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 424 jeremybenn
// { dg-require-namedlocale "" }
2
 
3
// Copyright (C) 2003, 2005, 2009 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 3, 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 COPYING3.  If not see
18
// <http://www.gnu.org/licenses/>.
19
 
20
// 22.1.1.2 locale constructors and destructors [lib.locale.cons]
21
 
22
#include <new>
23
#include <locale>
24
#include <cstdlib>
25
#include <cstring>
26
#include <testsuite_hooks.h>
27
 
28
int times_to_fail = 0;
29
 
30
void* allocate(std::size_t n)
31
{
32
  if (!times_to_fail--)
33
    return 0;
34
 
35
  void* ret = std::malloc(n ? n : 1);
36
  if (ret)
37
    std::memset(ret, 0xbc, n);
38
  return ret;
39
}
40
 
41
void deallocate(void* p)
42
{
43
  if (p)
44
    std::free(p);
45
}
46
 
47
void* operator new(std::size_t n) throw (std::bad_alloc)
48
{
49
  void* ret = allocate(n);
50
  if (!ret)
51
    throw std::bad_alloc();
52
  return ret;
53
}
54
 
55
void* operator new[](std::size_t n) throw (std::bad_alloc)
56
{
57
  void* ret = allocate(n);
58
  if (!ret)
59
    throw std::bad_alloc();
60
  return ret;
61
}
62
 
63
void operator delete(void* p) throw()
64
{
65
  deallocate(p);
66
}
67
 
68
void operator delete[](void* p) throw()
69
{
70
  deallocate(p);
71
}
72
 
73
void* operator new(std::size_t n, const std::nothrow_t&) throw()
74
{
75
  return allocate(n);
76
}
77
 
78
void* operator new[](std::size_t n, const std::nothrow_t&) throw()
79
{
80
  return allocate(n);
81
}
82
 
83
void operator delete(void* p, const std::nothrow_t&) throw()
84
{
85
  deallocate(p);
86
}
87
 
88
void operator delete[](void* p, const std::nothrow_t&) throw()
89
{
90
  deallocate(p);
91
}
92
 
93
// libstdc++/12352
94
void test01(int iters)
95
{
96
  bool test __attribute__((unused)) = true;
97
 
98
  for (int j = 0; j < iters; ++j)
99
    {
100
      for (int i = 0; i < 100; ++i)
101
        {
102
          times_to_fail = i;
103
          try
104
            {
105
              std::locale loc1 = std::locale("");
106
              std::locale loc2(loc1, std::locale::classic(),
107
                               std::locale::numeric);
108
            }
109
          catch (std::exception&)
110
            {
111
            }
112
        }
113
    }
114
}
115
 
116
int main(int argc, char* argv[])
117
{
118
  int iters = 1;
119
  if (argc > 1)
120
    iters = std::atoi(argv[1]);
121
  if (iters < 1)
122
    iters = 1;
123
  test01(iters);
124
 
125
  return 0;
126
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.