new.c
来自「linux下的gcc编译器」· C语言 代码 · 共 26 行
C
26 行
// Bug: new doesn't make sure that the count is an integral value.#include <new>extern "C" int printf (const char *, ...);extern "C" void *malloc (size_t);size_t s;void * operator new (size_t siz) throw (std::bad_alloc) { if (s == 0) s = siz; else s = (s != siz); return malloc (siz);}int main(){ s = 0; float f = 3; int* b1 = new int[(int)f]; int* b2 = new int[f]; // ERROR - new requires integral size return s;}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?