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

Subversion Repositories scarts

[/] [scarts/] [trunk/] [toolchain/] [scarts-gcc/] [gcc-4.1.1/] [gcc/] [testsuite/] [g++.dg/] [expr/] [anew4.C] - Blame information for rev 12

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 12 jlechner
// { dg-do run { xfail *-*-* } }
2
// XFAILed until PR2123 is fixed
3
// PR 11228: array operator new, with zero-initialization and a variable sized array.
4
// Regression test for PR
5
// Author: Matt Austern 
6
 
7
#include 
8
#include 
9
#include 
10
 
11
struct B
12
{
13
  B();
14
  int n;
15
};
16
 
17
B::B()
18
{
19
  n = 137;
20
}
21
 
22
 
23
struct D : public B
24
{
25
  double x;
26
};
27
 
28
 
29
D* allocate(int n)
30
{
31
  void *p;
32
  p = malloc(n * sizeof (D));
33
  memset (p, 0xff, n * sizeof(D));
34
  return new (p) D[n]();
35
}
36
 
37
int main()
38
{
39
  const int n = 17;
40
  D* p = allocate(n);
41
  for (int i = 0; i < n; ++i)
42
    if (p[i].n != 137 || p[i].x != 0)
43
      abort ();
44
  exit (0);
45
}

powered by: WebSVN 2.1.0

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