[question] сpp-test: own global delete operator

Hi all!

There is the cpp-test “p755a.cpp”:

// It checks to see if you can define your own global delete operator.
extern “C” void _exit(int);
void operator delete(void p) throw() {
int main () {
i = new int;
delete i;
return 1;

clang-3.8 returns 0 with O0 and returns 1 with O1
gcc always returns 0

clang with O1 uses default “delete”:

clang-3.8 -c -S p755a.cpp -O1

main: # @main

BB#0: # %entry

movl $1, %eax
.size main, .Lfunc_end1-main

As far as I understand it is not right…

I will be grateful to get any explanations.

I haven’t tested clang 4.0 yet…

C++ compilers are allowed to delete paired new/delete expressions after N3664, which I believe was voted into C++14. If you do not want this behavior, call ‘::operator new/delete’ instead.