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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-old/] [gcc-4.2.2/] [gcc/] [testsuite/] [g++.dg/] [init/] [array15.C] - Blame information for rev 816

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 149 jeremybenn
// { dg-do run }
2
 
3
// Copyright (C) 2004 Free Software Foundation, Inc.
4
// Contributed by Nathan Sidwell 8 Dec 2004 
5
 
6
// PR 16681 too much memory used
7
// Origin:  Matt LaFary 
8
 
9
struct foo {
10
  unsigned char buffer[4111222];
11
  foo() ;
12
  bool check () const;
13
};
14
 
15
foo::foo ()
16
  : buffer()
17
{}
18
 
19
bool foo::check () const
20
{
21
  for (unsigned ix = sizeof (buffer); ix--;)
22
    if (buffer[ix])
23
      return false;
24
  return true;
25
}
26
 
27
void *operator new (__SIZE_TYPE__ size, void *p)
28
{
29
  return p;
30
}
31
 
32
char heap[5000000];
33
 
34
int main ()
35
{
36
  for (unsigned ix = sizeof (heap); ix--;)
37
    heap[ix] = ix;
38
 
39
  foo *f = new (heap) foo ();
40
 
41
  if (!f->check ())
42
    return 1;
43
  return 0;
44
}
45
 
46
 

powered by: WebSVN 2.1.0

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