Rebase.
[official-gcc.git] / gcc / testsuite / g++.dg / init / array15.C
blob17160d07611b80978b8cb8593fa77edf01345cd5
1 // { dg-do run }
3 // Copyright (C) 2004 Free Software Foundation, Inc.
4 // Contributed by Nathan Sidwell 8 Dec 2004 <nathan@codesourcery.com>
6 // PR 16681 too much memory used
7 // Origin:  Matt LaFary <lafary@activmedia.com>
9 struct foo {
10   unsigned char buffer[4111222];
11   foo() ;
12   bool check () const;
15 foo::foo ()
16   : buffer()
19 bool foo::check () const
21   for (unsigned ix = sizeof (buffer); ix--;)
22     if (buffer[ix])
23       return false;
24   return true;
27 void *operator new (__SIZE_TYPE__ size, void *p)
29   return p;
32 char heap[5000000];
34 int main ()
36   for (unsigned ix = sizeof (heap); ix--;)
37     heap[ix] = ix;
38   
39   foo *f = new (heap) foo ();
41   if (!f->check ())
42     return 1;
43   return 0;
46