fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4.  
  5.  
  6. class A {
  7. public:
  8. A(){
  9. cout << "constructor" << endl;
  10. throw 1;
  11. }
  12. ~A() {
  13. cout << "Destroying" << endl;
  14. }
  15. };
  16.  
  17. void* operator new(size_t size, int i){
  18. cout << "in placement new" << endl;
  19. return ::operator new(size);
  20. }
  21.  
  22. void operator delete(void *ptr, int i){
  23. cout << "in placement delete" << endl;
  24. ::operator delete(ptr);
  25. }
  26.  
  27. int main(){
  28. int o = 9;
  29. // try {
  30. A* a = new(o) A;
  31. // } catch(...) {}
  32. }
  33.  
  34.  
Runtime error #stdin #stdout #stderr 0s 15240KB
stdin
Standard input is empty
stdout
in placement new
constructor
stderr
terminate called after throwing an instance of 'int'