#include <cstdlib> struct S { void *operator new(std::size_t) { i = 10; return nullptr; } int i; };
Standard input is empty
prog.cpp: In static member function ‘static void* S::operator new(std::size_t)’: prog.cpp:9:9: error: invalid use of member ‘S::i’ in static member function int i; ^ prog.cpp:5:9: error: from this location i = 10; ^ prog.cpp:6:16: warning: ‘operator new’ must not return NULL unless it is declared ‘throw()’ (or -fcheck-new is in effect) [enabled by default] return nullptr; ^
Standard output is empty