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

    <tr>
        <th>Summary</th>
        <td>
            Wrong behavior of PointerIntPair due to strict aliasing violation
        </td>
    </tr>

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

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

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

<pre>
    For some interfaces like "copy constructor", the PointerIntPair uses the underlying storage as it's declared: `intptr_t`.
However in other interfaces, like `getAddrOfPointer`, it `reinterpret_cast`s the storage into a pointer to the pointer: `int**`.

This is a strict aliasing violation and can cause wrong code generation if the compiler decides to optimize based on this information:
https://godbolt.org/z/n5E8f7jK1

In the example above the compiler generate the wrong code (abort is invoked). Any small tweak to the code can make it pass.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJx1k01v2zAMhn-NfSFm2HIcJwcfsnXBih3Ww4AdC1mibTWyZEhysvTXj1LatSswwF8kRfLRS7m38todrQNvZwRlArqBC_Sg1QkhY0zY5QrCGh_cKoJ15MrYFwgTwoNN6-9NeODKweopLfpXI9HpqzIjeMrgIwL3oELGWg8SheYOZVYfINuWVGEJ7jHQZ5GVd1l5-GYveEZHLGCpmnsHFRvfuLbliOEgpfsxvFCQK4ZViEGHybc4DI-C-1j9hvbKQ2ELHJZbLpARoy_mG1rGDvH6y3Z7_pwUbcdTPomiRACuFfdxu2dlNQ_KGuBGguCGbpIFLs5SVFiJMKJBd1ujhtRV2HlRmihIGiWjhhbsEtSsnhF67lECLQ6pqRmsm1M2Qd5ophAWHy12pGu0src6FNaNZD3TbZqvu6F9-l6938K9Sa3xN58XTePp7Rn_hXnhvHnf8WdsR6tdgIRzticaJdsXcDBX8DPXGsIF-elV0pQThZg5zY2ms3Dvi1x2tdzXe54HFTR2v1L9HidOCjqww8ezJVeMFf-rd7463X1QQoVp7QvaEBlan19fnxZnn1DQbI_K-zWeqmPTVGWdT912J3jF2H6omrZlpWh3LdttNttW4FDRd655j9p3WfOZ_gODF0gl4j_R3OWqYyVj5YZtqUZVs6JuttjyCrHelbJsq2xT4syVLiJHHFHuuoTUr6OnoFY--LcgKaVGg5jaUX2-hsm6rndo7LiqOU_NuwT_Bw7lRdM">