<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/108149>108149</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
std::unique_ptr destructor behaviour differs from (naïve?) expectations
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
zeule
</td>
</tr>
</table>
<pre>
The unique_ptr is widely advertised as a drop-in replacement for raw pointers. In this regard, libc++ implementation of the unique_ptr destructor differs in behaviour from `delete <raw-pointer>` and what GCC and MSVC libraries do: libc++ calls reset() in the destructor, which first clears the pointer and then calls deleter. Which means that when the destructor of the contained object is executed, the link between the owner of the unique_ptr object and the contained object is broken. That is not the case for raw pointers and unique pointers from GCC and MSVC STLs.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJxskkGPmz4QxT-NuYyCwCQEDhyy-f-pKrWnXbXHythDcNfY1B7Cbj99ZcIqXXVPCHh-7-eZJ0LQF4vYsMMDO_yXiJkG55vfOBtMOqdem6cBYbb614w_JvKgAyxaoXkFoa7oSQdUIAIIUN5NO23B42SExBEtQe88eLHA5LQl9CGFzxZo0AE8XoRXjJ_B6E4y_sD4A-hxMutBQdpZcD3Q-3SFgfwsyXlQuu_RB9AWOhzEVbvZQ-_dCKzMFBokBFacvVh2Wzor_mdlBsIqWAZB8Ol8Xl--Pn5bKbzwGgMox4rT31RSGBOBAxLjFeN1zIxgd5p4j2XQcoBe-0AgDQofVtEWvibRgHazuxH6FL6vx0YUNuoFwRJF7-3fJiGdJaEtKnDdT5QUt4EvKGfCdZRRY7R9hg5pwc3GLRb9B7PcLDauD707757RpvAUuXQA6-imFQH_2e3qdPO_f1sX8m7Qj09fQpqoplB1UYsEm_zIy6yo8pwnQ1OXZZ-p8tDl-74v5KHs-V7VPOuEKg57rBLd8IzvszrPs2OWH3jK87qojkeVd5WspBBsn-EotEmNuY6p85dEhzBjk2dVvq8TIzo0Ya075xYXWP8yzmP7fRMP7br5Etg-MzpQuNuQJoNNIMWKEytOH7fyXsW3ft4qySsr2Llgp_aKrGhjifBlQnlrekhmb5qBaArRnLeMtxdNw9yl0o2MtxFie-wm7-J-GG9X9MB4u93t2vA_AQAA__961k6N">