Files
codeql/cpp/ql/test/library-tests/syntax-zoo/allocators.cpp
Jeroen Ketema ee19c3d80f C++: Rename identically named classes in syntax-zoo
Conceptually the test that comprises the whole of `syntax-zoo` forms one
single binary. To this binary ODR applies. There were two class definitions
`Foo` in `syntax-zoo`, violating ODR. Rename those classes to have different
names.
2023-01-17 19:02:40 +01:00

21 lines
413 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;
};
int main()
{
auto foo = new(11, 22) Allocators(33, 44);
delete foo;
}
// semmle-extractor-options: --microsoft