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

    <tr>
        <th>Summary</th>
        <td>
            Capture of `*this` in explicit object parameter lambda doesn't respect qualifiers
        </td>
    </tr>

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

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

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

<pre>
    ```cpp
struct S {
  int x;

  auto foo() {
    return [*this](this auto&&) {
      __builtin_printf("%d ", x);
      x = 10;
    };
  }
};

int main() {
  S s{ 5 };
  const auto l = s.foo();
  l();
  s.x = 15;
  l();
 __builtin_printf("%d\n", s.x);
}
```
https://godbolt.org/z/35qjr473K

Expected: an error that you cannot modify `x` within a `const` lambda.

Result: Prints `5 10 15`, demonstrating both that `l` has captured a copy of `S`, and also that (despite being a `const` object) it is nevertheless mutating its own state.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJx8U01v4zgM_TX0hRhDkfwRH3xom81lL4vtDyhkm4k1kCWPRE_T_fUL2e5M2mIXMKKQIp_ee5R0jObqiFooH6E8ZXrh0Yf2NZAhl3V-eGuhEtvXzzOIE4iHyGHpGZ8R6sctg2gc4w3UHr9n9cIeL96DPIJs7usRA_ESHKaD5QOPJkJ5AnlM_9Y-kNX6fWpDfHnpFmPZuJc5GMeXFVyCLAdc1ye8gWx-cdmabgjqhAfxIQ316S5O0cb-Lr39JnWTNu6rjmeMUD9i-Qmr9y7yJt-uJ8f8lw13ZfZLJuY70_L_yv7bAiif3O5CzD_48Fve-0C3cGSeI6gHkGeQ56sfOm859-EK8vwPyLMqf3wPRa3-vDfkj9tMPdMA6gG1QwrBB-RRM775BXvtnGec_GAubwiVuEEl8NXwaBzqlFj9SUmrp27Q-T323xQXywn5ryQupvoSDyJ5UomkbKAp9QfNxl2x8zxuZ0MlbAIddcRez7wEGlBj7-c39Je0_bwjaDegttHvffI4UJwNE3aUID9y9N136jkN3jCaiI5-UuCRLMWI08IbDcMR_avDyJopz4ZWDY1qdEbtoRZNrcRBiWxsOy0KURyU7o6ybnSnVNFXJYl6uPTNpawy00ohC6FEdVBCiiZvClFUnaaiL6hUfQmFoEkbm1v7c0qDykyMC7XH4lCpzOqObFzfs5SOXnHdTFeiPGWhTT3fuuUaoRDWRI6_UdiwpfZp82336_1pVgKNQ7rN1vSGd0dw1kFPxBT2MeLgKTqQNWOgmG4I_li0NRdDIWZLsO2ny2Z4XLq89xPIc-KxL9_m4DfLzyv7CPK8qvs3AAD__4bYWjE">