PR c++/81917 - ICE with void_t and partial specialization.
[official-gcc.git] / gcc / testsuite / g++.dg / opt / temp2.C
blob35520a2427c839e27752be624eb252e3544d8ca4
1 // { dg-do run }
3 // Copyright (C) 2006 Free Software Foundation, Inc.
5 // Originally from PR 16681, found also in init/array15.C
6 // This variant of the testcase verifies that we do not create
7 // a temporary on the stack, which is PR 27620.
9 int i;
11 extern "C"
12 void *memcpy (void *dest, const void *src, __SIZE_TYPE__ n)
14   char *d = (char *) dest;
15   const char *s = (const char *) src;
16   while (n--)
17     d[n] = s[n];
18   ++i;
19   return dest;
22 struct foo {
23   unsigned char buffer[41112];
24   foo() ;
25   bool check () const;
28 foo::foo ()
29   : buffer()
32 bool foo::check () const
34   for (unsigned ix = sizeof (buffer); ix--;)
35     if (buffer[ix])
36       return false;
37   return true;
40 void *operator new (__SIZE_TYPE__ size, void *p)
42   return p;
45 char heap[50000];
47 int main ()
49   for (unsigned ix = sizeof (heap); ix--;)
50     heap[ix] = ix;
52   i = 0;
53   foo *f = new (heap) foo ();
55   if (i != 0)
56     return 1;
57   if (!f->check ())
58     return 1;
59   return 0;
62