URL
https://opencores.org/ocsvn/openrisc_me/openrisc_me/trunk
Only display areas with differences |
Details |
Blame |
View Log
Rev 149 |
Rev 154 |
// { 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);
|
}
|
}
|
|
|
© copyright 1999-2024
OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.