new1.c
来自「this is a gcc file, you can download it 」· C语言 代码 · 共 41 行
C
41 行
// 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[] (size_t s) throw (std::bad_alloc){ 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() {}};intmain (){ try { A *p = new A[4]; } catch (...) {} return ret;}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?