i instrumenting code , noticed c++14 features there 2 new delete
operators (from http://en.cppreference.com/w/cpp/memory/new/operator_delete):
these 5-6) called instead of (1-2) if user-defined replacement provided except it's implementation-defined whether (1-2) or (5-6) called when deleting objects of incomplete type , arrays of non-class , trivially-destructible class types (since c++17). standard library implementations identical (1-2).
i have overloaded these , wanted call these 2 exclusively. when overload these 2 gcc don't have problem. clang++ undefined reference operator delete(void*)
here code
void* operator new(long unsigned int howmuch) { return reinterpret_cast<void*>(0xdeadbeef); } void* operator new[](long unsigned int howmuch) { return reinterpret_cast<void*>(0xdeadbeef); } void operator delete(void* what, long unsigned int howmuch) { if(what != reinterpret_cast<void*>(0xdeadbeef)) __builtin_trap(); if(howmuch != 1) __builtin_trap(); } extern "c" void _start() { delete new char; asm("syscall" : : "a"(60) : ); }
compiled gcc: g++ -ggdb -std=c++14 -nostdlib -fno-builtin -fno-exceptions 1.cc
there no problem , runs fine.
is possible llvm/clang?
Comments
Post a Comment