Files
codeql/cpp/ql/test/library-tests/syntax-zoo/allocators.cpp
Jeroen Ketema f649def3f8 C++: Silence a number of bogus consistency errors in syntax zoo
These were due to several functions occurring that would have the same TRAP
key. By making the functions static the TRAP keys will differ from each other.
2023-03-03 11:16:19 +01:00

21 lines
417 B
C++

struct Allocators
{
Allocators(int x, int y) : m_x(x), m_y(y) {}
~Allocators() {m_x = m_y = 0;}
// NB: In Microsoft mode, size_t is predeclared.
static void* operator new(size_t sz, int z, int w) { return nullptr; }
static void operator delete(void* self) {}
int m_x;
int m_y;
};
static int f()
{
auto foo = new(11, 22) Allocators(33, 44);
delete foo;
}
// semmle-extractor-options: --microsoft