<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/96980>96980</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            Possibly undefined `delete` due to unsafe conversion of unique_ptr
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          leni536
      </td>
    </tr>
</table>

<pre>
    https://github.com/llvm/llvm-project/blob/868b90df07e08617a9be33178ac33437aaa00942/llvm/lib/IR/Constants.cpp#L2819-L2835

`ConstantDataSequential` is a non-polymorphic base class of `ConstantDataArray` and `ConstantDataVector`.
`*Entry` is `unique_ptr<ConstantDataSequential>` and it gets to own either a dynamically allocated `ConstantDataArray` or `ConstantDataVector`, but at the end of its lifetime it deletes the owned object through a pointer of `ConstantDataSequential`. As `ConstantDataSequential` has no virtual destructor, this is undefined behavior.

The undefined behavior might manifest benignly or less benignly depending whether sized deallocation functions are enabled.

The bug was found by a reference implementation of https://wg21.link/P2413R1 .
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyUlEmPpDYUxz-NuTwNMoZiOXCodE9JkeYwmkS5Rs_2A5wYm_FSJfLpI6q7p3u2SLkAwm_5-f8WjNHMjmhkp1_Y6bHAnBYfRkvOnOq2kF7v45LSFll9ZuLCxGU2acmyVH5l4mLt9eX1bgv-L1KJiYu0XjJx6dteDlxPvCPet1WHg6S6rroeVV03dYeInA-NeBPHHH6_fmLi8uBdTOhSLNW2MVF_EH01vPsg-vrE-CPj5-dny18sHzHhb_Q5k0sGLWs5mAgIzrt3m7f76sO2GAUSI4GyGCP4Cb7xP4eA--GKTn979gep5ANrefklNRPn9y6F_TkZa3l25nOmP7cUWP3wE7L6_UsGk2CmFCF58DcHZNJCARD07nA1Cq3dAa31ChN9x_OF1YefojLxADInwARpISCnj0ubFMGaiZJZ6WDQZClRvJv4myMNXh6lhLQEn-cFEDZvXKLwA8m-kryEc_xPA1gwgvNwNSFltKApppDvtOIB0mLiIWR2miZzgEha8Gp8KN8W_feFfmACq5mXBCs6M1FMIMmZ2dn90MdSjK8_NG3ktHEz3Ba6Sx7NP6RB07PYxjuYslPHRwQMh3IoLenvMGSe4YYRJp-dBrkDQqCJAjlFYNbN0kouPUX0E3w9SrdZVKU17m8mLh9FU9WfKigLPdZ6qAcsaKy6ajiJvuFdsYy66no5SaRT26pBnTQOSinspNSy74ahMKPgouGt6IRo2qYrm7ofhkoqPgykOVWs4bSiseUxbqUPc2FizDQO7dDzwqIkG--LQAhHN7gfMiGOvRDG-4zLPEfWcGtiiq9RkkmWxo8-RiPt_qY0rOVPvXVUXmc6Gj27iBOB8u5KIT7r8jo2RQ72_2-cO2pk4vJ0leso_g0AAP__59OeHg">