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

    <tr>
        <th>Summary</th>
        <td>
            `return` statements in statement expressions in unevaluated contexts are ignored
        </td>
    </tr>

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

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

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

<pre>
    Related: #77754

```c++
struct unrelated_type {};

int main() {
    void(* p)() noexcept = []() noexcept(({ return unrelated_type{}; true; })) {};
    bool(* q)() = []() -> decltype(({ return unrelated_type{}; true; })) { return true; };
 unrelated_type(* r)() = []() -> decltype(({ return 0; unrelated_type{}; })) { return {}; };
}
```

This compiles on Clang 18 (`-std=c++11 -x c++ -fsyntax-only`).

`p` and `q` should definitely not compile: Either the `return` applies to the new lambda scope (in which case, it is an incompatible type to `void`/`bool`), or it applies to `int main()` (where it is still incompatible with `int`). In either case, it should not be a constant expression for `p`'s `noexcept` specifier.

`r` may or may not be correct, depending on what scope the `return` should return from.

</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyklM2O4zYMx59GvhAJbDnxx8GHZLMBeuil6L2QbTpWK0teiZ4kb19Q8c5kMu2lBYLIEk3yR_IvqxD0xSI2Yn8U-1OiFhqdb37VpMwhjO6vpHX9vfkNjSLsRX4AIfOyLPc7kZ5Eelj_i_Tx64Q88i-eBvJLR7BY__D-g-4zgiiPojyJ_PgcQFuCSWkrZCVkHd-J5wAAb0738fwAs5D1-op1eOtwJhD5CR7wL5a4rUR5BI-0ePsC8s4B5Bfklbccv35lZIrWObNS_Pig-JJ8I_Lv0GNnYor_RfDT6dn4TvQS6QHm_zNYygn-je4fqT6b36dZnl4U8Tzl30cdoHPTrA0GcBa-GWUvkFXANEW6CdSL_LSKKMtgc4N1A5sh3C2p28ZZc-e4st6-SHAWRQrK9iCK9Ac_h9EtpoceB201obmDdfQTgLX8XdOIHmhE9nlUFoPMs9EYgFy0WbyCUVPbKwidYw3LSlu4jroboVMBhfwGmkAHUBa05QyKdGsQouTJcfioYwY_iyKNcopVsK_z7P6UVRTp5yvBVEJW1xE9rqkCaWM-Z7tqGlfftUXwiwV8VPkEujaGu9EiKOicDaQsAd5mjyFoZ2FwHtamClkGfn6_WdzbGTs9aPSvU_BsndSdi-JlTdI577EjBuhxRttre2EJXEdFa1e_jGHFXBU3eDetyZK-yfs6r1WCTVamu7reF7lMxkbm3TCoIWuHNq1kKbMM922VF9jtsiGrd4luZCp3aZZlWbnP93KbFZ2qi7Tu-11dy7oVuxQnpc3WmLdp6_wl0SEs2JRllVaJUS2aED-WUrIsolFIyd9O37DPpl0uQexSowOFjyikyWDzuTxShBNaCqDtx-5pCNGwWHxTZuGLyYMivFEAxTK4WOexTxZvmpFoDiI_sLrk-aJpXNpt5yYhz4ywLpvZuz_jFM4RPAh5joX9HQAA___0j85p">