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

    <tr>
        <th>Summary</th>
        <td>
            Permitted assignment of read-only capture in not-mutable lambda
        </td>
    </tr>

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

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

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

<pre>
    This program
```
struct B {
    int i;
};

int foo() {
    auto [x] = B{1};
    [x]() {
 x = 2;
    }();
    return x;
}
```
is invalid because not-mutable lambda modifies its read-only capture `x`, and it is properly rejected by GCC and MSVC, but Clang erroneously admits it. Online demo: https://gcc.godbolt.org/z/46o6jad8n
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJxsUs2O2zwMfBr6QiSw5f-DDpsE_k4fWqBF75LFOFrIUqCfbdKnL5QE2KYNYNgWNTMkhxQh6MUScWh30B4KkeLJeT6R8oV06sq_n3TAs3eLFyuUByjfoCsfz-0Yok9zxB1Cv7tHEBG1jaihfkSgP3z-3975_ugcsAHY-EwVKTqEdneB9oBQH3AH_a76UyKjHoB_BC43CnvG9g_cU9RTTN7i5anKVx3qgNp-CKMVSppFCoTWxc2aopCG0IhVKoGrU_qoKaCOAT0JtXHWXHEW55g8IXTlJSuyPQqrUEe8-3omb67o6Z3mSArlFf_b3yH_f_uxz3CZIu6NsAuS986SS8FcUag1J9Jxi1-s0ZZQ0eqgfsNTjOcA9RuwCdi0zPN2cUo6E7fOL8CmX8CmpnPdu1CDLRSv1ViPoiBe9dVQjnXdV8WJt6xqju0wi74-CtXLqpe9oqFp64basWeF5qxkTdlVVZlZ1bZsBuqo7xgNY6fGDpqSVqHN1piPNecudAiJ-NiWQ1UYIcmE29oxZukn3i6BsbyFnmfORqYlQFMaHWL4VIk6GuJfya86ZsvuK7ySjeiOL5zX9sW4iuQN_8spHU9Jbme3Aptytsdnc_YuTwfYdKsxAJvuPXxw9jsAAP__KF74KQ">