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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [testsuite/] [g++.dg/] [init/] [value3.C] - Blame information for rev 693

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 693 jeremybenn
// Testcase for value-initialization in new-expressions.
2
// { dg-do run }
3
 
4
#include 
5
#include 
6
 
7
// Make sure that we return memory that isn't already set to 0.
8
void *operator new(size_t s)
9
{
10
  void *p = malloc (s);
11
  memset (p, 42, s);
12
  return p;
13
}
14
 
15
struct A { A() {} ~A() {} };
16
struct B { A a; int i; };
17
 
18
int main()
19
{
20
  B *p = new B();
21
  if (p->i != 0)
22
    abort();
23
 
24
  p = new B[2]();
25
  if (p[0].i != 0 || p[1].i != 0)
26
    abort();
27
 
28
  B(*p2)[2] = new B[2][2]();
29
  if (p2[0][0].i != 0 || p2[0][1].i != 0)
30
    abort();
31
}

powered by: WebSVN 2.1.0

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