我正在检测一些代码,并注意到有了C++ 14的功能,有两个新的delete运算符(来自http://en.cppreference.com/w/cpp/memory/new/operator_delete):
这些是5-6)如果提供了用户定义的替换,则调用而不是(1-2),除了它的实现定义在删除不完整类型和数组的对象时是否调用(1-2)或(5-6)非类和易破坏的类类型(自C++ 17以来).标准库实现与(1-2)相同.
我已经超载了这些并且想要专门调用这两个.当我用gcc重载这两个时,我没有问题.使用clang ++我得到一个未定义的引用operator delete(void*)
这是代码
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) : ); 
}
Run Code Online (Sandbox Code Playgroud)
用gcc编译:g++ -ggdb -std=c++14 -nostdlib  -fno-builtin  -fno-exceptions 1.cc没有问题,运行正常.
用llvm/clang可以做到这一点吗?