blob: 0ac2562d7f97f3e7810a0b55b85b3cd056da2288 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
// 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);
}
main()
{
s = 0;
float f = 3;
int* b1 = new int[(int)f];
int* b2 = new int[f];
return s;
}
|