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/] [expr/] [anew3.C] - Blame information for rev 378

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

Line No. Rev Author Line
1 301 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.