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

    <tr>
        <th>Summary</th>
        <td>
            [clang][CodeGen] Assertion failed on isa<To>(Val).
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            clang
      </td>
    </tr>

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

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

<pre>
    The line of code "assert(isa<To>(Val) && "cast<Ty>() argument of incompatible type!");"  had been added into  "[[nodiscard]] inline decltype(auto) cast(From *Val)" in [a65bb](https://github.com/llvm/llvm-project/commit/f0d2a55d3aa68827ad708a16650bb0b341ca65bb) by @preames  which causes bugs to #https://github.com/llvm/llvm-project/pull/87332 .

Error Messages: 
Assertion `detail::isPresent(Val) && "dyn_cast on a non-existent value"' failed for windows. 
Assertion failed: detail::isPresent(Val) && "dyn_cast on a non-existent value" for linux.

Build Info:
[github-pull-requests_build_52112_linux-linux-x64.log](https://github.com/llvm/llvm-project/files/14851602/github-pull-requests_build_52112_linux-linux-x64.log)
[github-pull-requests_build_52112_windows-windows-x64.log](https://github.com/llvm/llvm-project/files/14851611/github-pull-requests_build_52112_windows-windows-x64.log)

</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJysVMuO4zYQ_JrWpWGDar2ogw72eh3kECCHRa4GJbZsBjTpkNTO-O8DSpkESTbATjAXUlCTVdUPlorRXB3zAM0RmlOhlnTzYTDacmjbYvT6OXy5MVrjGP2Mk9eMQKRi5JCApIkKqk9fPFSfgeQvygL1CNQCtfncpGLK8ecWz0EVrsudXcpwxk3-_lDJjJYxPR8MVAIRUA_VEYgQb0rjyOxQac0ajUseM_Cq9-i8NnFSQUNzguaExq1CNU92Q5NqST6zrkJInoO_I9BhE5oZjENojqptxjGDkLyl9IhQHYDOQOerSbdl3E_-DnS29uvbtnsE_ytPCeg8-fvd5I9ZaFJNoyulWimpU7oTUpVt24hxFGNVl9PGQz2OT4RaPAKrO0fEl5uZbjipJXLEcblGTB6BqneLeSzWAp1lV1WEexAnEIdt_RyCD_gTx6iunDFx-39YW2m8Q2iF5qSMzYTVwcSfA0d26VuN1U93yTVF71Ch827Hryam3Nevyi68drHDWRnLGmcf8MU47V_i_l-025ks6CPZV05r3PL6tyocF2M1_uhmn2m2QHPcCrvLxdsF_m3hmOJlzEcvDZUlXVag3ba-tvXe-uv_nJbZWI5A57KWTdkK-vPWO9mp_371f5R-97Z_ZAZl-T0Z_JeCtywKPVS6r3pV8FB2JZV115ddcRu4q4lFrWSnSLddr6pJjj118zTOvda6MAMJqkUtqpIqWXV7UY1NKxsx6bYsxdxBLfiujN3nNPY-XAsT48KD7GrZFlaNbONqf0STVe66msupCMOadn6LUAtrYop_ISST7OqZ241sPsdPXvMP7LIN_XO285h-yyj3xRLs8O4GrPrj-spr2f4eAAD__0yJ0Q4">