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

Subversion Repositories openrisc

[/] [openrisc/] [tags/] [gnu-src/] [gcc-4.5.1/] [gcc-4.5.1-or32-1.0rc1/] [gcc/] [testsuite/] [g++.dg/] [expr/] [anew1.C] - Diff between revs 301 and 338

Only display areas with differences | Details | Blame | View Log

Rev 301 Rev 338
// { dg-do run }
// { dg-do run }
// PR 11228: array operator new, with zero-initialization and a variable sized array.
// PR 11228: array operator new, with zero-initialization and a variable sized array.
// Regression test for PR
// Regression test for PR
// Author: Matt Austern 
// Author: Matt Austern 
#include 
#include 
#include 
#include 
#include 
#include 
int* allocate(int n)
int* allocate(int n)
{
{
  void *p;
  void *p;
  p = malloc(n * sizeof (int));
  p = malloc(n * sizeof (int));
  memset (p, 0xff, n * sizeof(int));
  memset (p, 0xff, n * sizeof(int));
  return new (p) int[n]();
  return new (p) int[n]();
}
}
int main()
int main()
{
{
  const int n = 17;
  const int n = 17;
  int* p = allocate(n);
  int* p = allocate(n);
  for (int i = 0; i < n; ++i)
  for (int i = 0; i < n; ++i)
    if (p[i] != 0)
    if (p[i] != 0)
      abort ();
      abort ();
  exit (0);
  exit (0);
}
}
 
 

powered by: WebSVN 2.1.0

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