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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [testsuite/] [g++.dg/] [eh/] [new1.C] - Rev 774

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

// PR c++/5757
// Test that when a constructor throws in a new-expression, we pass the
// right pointer to operator delete.

// { dg-do run }

#include <new>

int ret = 1;

void *ptr;
void * operator new[] (std::size_t s)
#if __cplusplus <= 199711L
  throw (std::bad_alloc)
#endif
{
  ptr = operator new (s);
  return ptr;
}

void operator delete[] (void *p) throw ()
{
  if (p == ptr)
    ret = 0;
  operator delete (p);
}

struct A
{
  A() { throw 1; }
  ~A() {}
};

int
main ()
{
  try
    {
      A *p = new A[4];
    }
  catch (...) {}
  return ret;
}

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

powered by: WebSVN 2.1.0

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