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

Daniil Troshkov via llvm-dev llvm-dev at lists.llvm.org
Thu Mar 30 09:51:09 PDT 2017


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() {
  _exit(0);
}
int main () {
  int* 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
    .cfi_startproc
# BB#0:                                 # %entry
    movl    $1, %eax
    retq
.Lfunc_end1:
    .size    main, .Lfunc_end1-main
    .cfi_endproc
...

As far as I understand it is not right...

I will be grateful to get any explanations.

PS
I haven't tested clang 4.0 yet...
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20170330/4a020618/attachment.html>


More information about the llvm-dev mailing list