[Bug c++/98840] Why does baz call the delete operator for moved unique_ptr
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98840 --- Comment #4 from Dmitriy Ovdienko --- What if introduce new ABI version and encode into function name (function name mangling). And then have two options: * Either compile code and store both versions into lib file (ABI v1 and v2). Applies only to functions that have arguments of the non-trivial class passed by value. * Or compile ABI v2 and then linker if can find referenced ABI v2 function uses it as is (assuming that v2 function destructs the object inside) or if v2 function is not found it calls v1 function and adds the code to destruct objects passed by value. That applies to destruction only. Stack is cleaned by calling function as before.
[Bug c++/98840] Why does baz call the delete operator for moved unique_ptr
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98840 --- Comment #3 from Dmitriy Ovdienko --- > This is not a GCC bug. No it is not. But can we improve that? That approach increases the binary size. In case if `baz` is called from many places, that is going to increase the binary size.
[Bug c++/98840] Why does baz call the delete operator for moved unique_ptr
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98840 --- Comment #2 from Jonathan Wakely --- https://www.youtube.com/watch?v=rHIkrotSwcc discusses exactly this problem. See also https://quuxplusone.github.io/blog/2018/05/02/trivial-abi-101/ This is not a GCC bug.
[Bug c++/98840] Why does baz call the delete operator for moved unique_ptr
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98840 --- Comment #1 from Jonathan Wakely --- The ABI requires it. The caller is responsible for constructing and destroying the argument.