Closed Quuxplusone closed 6 years ago
Bugzilla Link | PR35517 |
Status | RESOLVED INVALID |
Importance | P enhancement |
Reported by | Konstantin Morshnev (moko@design.ru) |
Reported on | 2017-12-04 06:27:54 -0800 |
Last modified on | 2017-12-06 09:33:53 -0800 |
Version | unspecified |
Hardware | PC All |
CC | dblaikie@gmail.com, dgregor@apple.com, efriedma@quicinc.com, llvm-bugs@lists.llvm.org, richard-llvm@metafoo.co.uk |
Fixed by commit(s) | |
Attachments | |
Blocks | |
Blocked by | |
See also |
This is how the ABI works. https://eli.thegreenplace.net/2015/c-deleting-destructors-and-virtual-operator-delete/ has a good description of deleting destructors.
Also, please use the cfe-dev mailing list, not the bugtracker, for questions about clang's behavior.
(In reply to Konstantin Morshnev from comment #0)
> Possibly it compiles in gcc after this change:
>
> http://patchwork.ozlabs.org/patch/604210/
FWIW, your testcase only compiles in GCC 6.1 because they changed their default
standard mode to C++14, and that causes your code to call "operator
delete(void*, size_t)" instead of "operator delete(void*)".
> has a good description of deleting destructors.
The description is clear and we know it. But it is about dynamic objects
(MyStruct *ss=new MyStruct), and we have a stack object (MyStruct ss).
And if you'll and some printfs (like https://godbolt.org/g/fW4QZk) you'll see,
that delete is not called. It looks like there are two destructor versions are
generated - one with delete call and one without. But if the one with delete is
not referenced, why it is not optimized out?
> FWIW, your testcase only compiles in GCC 6.1 because they changed their
default standard mode to C++14
Thx for this note.
P.S. As a workaround we are temporary disabling virtual destructors to check
that build-in delete is not used in our code, but it's not very convenient.
The deleting destructor is not optimized out because it's referenced by the vtable.