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