URL
https://opencores.org/ocsvn/openrisc/openrisc/trunk
Only display areas with differences |
Details |
Blame |
View Log
Rev 301 |
Rev 338 |
// Testcase for value-initialization in new-expressions.
|
// Testcase for value-initialization in new-expressions.
|
// { dg-do run }
|
// { dg-do run }
|
|
|
#include
|
#include
|
#include
|
#include
|
|
|
// Make sure that we return memory that isn't already set to 0.
|
// Make sure that we return memory that isn't already set to 0.
|
void *operator new(size_t s)
|
void *operator new(size_t s)
|
{
|
{
|
void *p = malloc (s);
|
void *p = malloc (s);
|
memset (p, 42, s);
|
memset (p, 42, s);
|
return p;
|
return p;
|
}
|
}
|
|
|
struct A { A() {} ~A() {} };
|
struct A { A() {} ~A() {} };
|
struct B { A a; int i; };
|
struct B { A a; int i; };
|
|
|
int main()
|
int main()
|
{
|
{
|
B *p = new B();
|
B *p = new B();
|
if (p->i != 0)
|
if (p->i != 0)
|
abort();
|
abort();
|
|
|
p = new B[2]();
|
p = new B[2]();
|
if (p[0].i != 0 || p[1].i != 0)
|
if (p[0].i != 0 || p[1].i != 0)
|
abort();
|
abort();
|
|
|
B(*p2)[2] = new B[2][2]();
|
B(*p2)[2] = new B[2][2]();
|
if (p2[0][0].i != 0 || p2[0][1].i != 0)
|
if (p2[0][0].i != 0 || p2[0][1].i != 0)
|
abort();
|
abort();
|
}
|
}
|
|
|
© copyright 1999-2024
OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.