URL
https://opencores.org/ocsvn/openrisc_me/openrisc_me/trunk
Subversion Repositories openrisc_me
[/] [openrisc/] [trunk/] [gnu-src/] [gcc-4.5.1/] [gcc/] [testsuite/] [g++.dg/] [init/] [value3.C] - Rev 307
Go to most recent revision | Compare with Previous | Blame | View Log
// Testcase for value-initialization in new-expressions.
// { dg-do run }
#include <stdlib.h>
#include <string.h>
// Make sure that we return memory that isn't already set to 0.
void *operator new(size_t s)
{
void *p = malloc (s);
memset (p, 42, s);
return p;
}
struct A { A() {} ~A() {} };
struct B { A a; int i; };
int main()
{
B *p = new B();
if (p->i != 0)
abort();
p = new B[2]();
if (p[0].i != 0 || p[1].i != 0)
abort();
B(*p2)[2] = new B[2][2]();
if (p2[0][0].i != 0 || p2[0][1].i != 0)
abort();
}
Go to most recent revision | Compare with Previous | Blame | View Log