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

    <tr>
        <th>Summary</th>
        <td>
            FR: Warn on ineffective use of std::bit_cast<>
        </td>
    </tr>

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

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

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

<pre>
    I propose warning on any use of std::bit_cast<> where source or destination types are pointers.

Such usage is technically safe and well-defined, but it's:
(1) Unnecessary, as reinterpret_cast<> is also safe and well-defined for this.
(2) A strong signal the user misunderstands bit_cast as "reinterpret_cast, but it's not UB".

In auditing Chromium and its third-party dependencies, we've found most usage of std::/absl::/etc.::bit_cast falls into the above bucket (~2500 uses in ~400 source files).
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyEk82OozoQhZ_GbEqJoMgPLFiku2-k3t6r1l2ODC7A046NXOVE2fSzj5z-mYlmpNmAEOacr84pNLOdPFGntg9q-1ToJHOI3fKqWayfij6Ya_cMSwxLYIKLjt76CYIH7a-QmCCMwGJUfVD1obfybdAsqn5U9T9wmSkScEhxIAgRDGVRLTZ4kOtCDDoSLMF6ochrVT6p8vB-_S8NMyTWE4FlEBpmbwft3BVYjwTaG7iQcytDo_VkFD5CnwSsKNxzhnnXwqZS2MKL9zQQs47XfFIzRLqZLpHuiC2Ddhz-bAJjiCCz_SLFBrP6AVhi8BPkKLUDmSknE-FkOXlDkUV7w_CZTvZXiL8h3M0APgi8PCjEu1yePehkbO4GHucYTjadbqBWOLNFs1p0lCsYWsgb8oMlzsoXUrg_E4wheQOnwPIR76_9KTzqnt3XA8mwvm8WRu0cg_USbnPqPpwJ-jS8koDC5g23ZZmnz2fgbVOWn_2P1mWSdl2YrjZt3eqCumpfVk2zR6yLuStN3TZUtwa12WE9ttW43ZjtZrsZe72rqLAdllhXWO6qBvdlvW53VUnY74eq322bslWbkk7aurVz59M6xKmwzIm6_WZXt4XTPTm-bTqipwvcXirEvPixy9-s-jSx2pTOsvBPFbHiqDv-q-oD_K-jz_tvPY0jDWLP9Jf_oEjRdbPIwu-pKjxOVubUr4dwUnjMNh-31RLDdxpE4fEGxwqPN_gfAQAA__9PgzG0">