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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-old/] [gcc-4.2.2/] [gcc/] [testsuite/] [g++.dg/] [expr/] [anew1.C] - Blame information for rev 841

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

Line No. Rev Author Line
1 149 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
 
7
#include 
8
#include 
9
#include 
10
 
11
int* allocate(int n)
12
{
13
  void *p;
14
  p = malloc(n * sizeof (int));
15
  memset (p, 0xff, n * sizeof(int));
16
  return new (p) int[n]();
17
}
18
 
19
int main()
20
{
21
  const int n = 17;
22
  int* p = allocate(n);
23
  for (int i = 0; i < n; ++i)
24
    if (p[i] != 0)
25
      abort ();
26
  exit (0);
27
}

powered by: WebSVN 2.1.0

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