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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [testsuite/] [g++.dg/] [expr/] [anew3.C] - Blame information for rev 754

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

Line No. Rev Author Line
1 693 jeremybenn
// { dg-do run }
2
// PR 11228: array operator new, with zero-initialization and a variable sized array.
3
// Regression test for PR
4
// Author: Matt Austern 
5
 
6
#include 
7
#include 
8
#include 
9
 
10
struct X
11
{
12
  int a;
13
  double b;
14
};
15
 
16
X* allocate(int n)
17
{
18
  void *p;
19
  p = malloc(n * sizeof (X));
20
  memset (p, 0xff, n * sizeof(X));
21
  return new (p) X[n]();
22
}
23
 
24
int main()
25
{
26
  const int n = 17;
27
  X* p = allocate(n);
28
  for (int i = 0; i < n; ++i)
29
    if (p[i].a != 0 || p[i].b != 0.0)
30
      abort ();
31
  exit (0);
32
}

powered by: WebSVN 2.1.0

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