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

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [gcc-4.5.1/] [gcc/] [testsuite/] [g++.dg/] [init/] [new27.C] - Blame information for rev 308

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 301 jeremybenn
// PR c++/34862
2
// { dg-do run }
3
// { dg-options "-O2" }
4
 
5
typedef __SIZE_TYPE__ size_t;
6
extern "C" void abort ();
7
 
8
struct T
9
{
10
  void *operator new (size_t, char *&);
11
  T () { i[0] = 1; i[1] = 2; }
12
  int i[2];
13
};
14
 
15
void *
16
T::operator new (size_t size, char *&p)
17
{
18
  void *o = (void *) p;
19
  p += size;
20
  return o;
21
}
22
 
23
T *
24
f (char *&x)
25
{
26
  return new (x) T ();
27
}
28
 
29
char buf[10 * sizeof (T)] __attribute__((aligned (__alignof (T))));
30
 
31
int
32
main ()
33
{
34
  char *p = buf;
35
  T *t = f (p);
36
  if (p != buf + sizeof (T))
37
    abort ();
38
  if (t->i[0] != 1 || t->i[1] != 2)
39
    abort ();
40
}

powered by: WebSVN 2.1.0

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