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

    <tr>
        <th>Summary</th>
        <td>
            Error on use of parameter in lambda outside function body
        </td>
    </tr>

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

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

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

<pre>
    Compiler Explorer link: https://godbolt.org/z/118sGzbbM

```cpp
void foo(auto x) noexcept(noexcept([&x] { x; })) {}

int main() {
        foo(3);
}
```
```
<source>:1:43: error: variable 'x' cannot be implicitly captured in a lambda with no capture-default specified
    1 | void foo(auto x) noexcept(noexcept([&x] { x; })) {}
 |                                           ^
<source>:1:41: note: while substituting into a lambda expression here
    1 | void foo(auto x) noexcept(noexcept([&x] { x; })) {}
      | ^
<source>:4:2: note: in instantiation of exception specification for 'foo<int>' requested here
    4 |         foo(3);
      | ^
<source>:1:15: note: 'x' declared here
    1 | void foo(auto x) noexcept(noexcept([&x] { x; })) {}
      | ^
<source>:1:36: note: lambda expression begins here
    1 | void foo(auto x) noexcept(noexcept([&x] { x; })) {}
      | ^
<source>:1:39: note: capture 'x' by value
    1 | void foo(auto x) noexcept(noexcept([&x] { x; })) {}
      | ^
      | x
<source>:1:39: note: capture 'x' by reference
    1 | void foo(auto x) noexcept(noexcept([&x] { x; })) {}
      | ^
      | &x
<source>:1:37: note: default capture by value
    1 | void foo(auto x) noexcept(noexcept([&x] { x; })) {}
      | ^
      |                                     =
<source>:1:37: note: default capture by reference
    1 | void foo(auto x) noexcept(noexcept([&x] { x; })) {}
      | ^
      |                                     &
<source>:1:43: warning: expression result unused [-Wunused-value]
    1 | void foo(auto x) noexcept(noexcept([&x] { x; })) {}
      | ^
<source>:4:2: note: in instantiation of exception specification for 'foo<int>' requested here
    4 |         foo(3);
 |         ^
1 warning and 1 error generated.
Compiler returned: 1
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzMVk1z4ygQ_TX40mWXAMmSDzr4c0973jOCts0OBi0fjpNfv4VkJ97MpCY1VTuxyyUBTdPvdSN4IgR9sIgtqVak2kxEikfn26186fDbpHPquV27U68NetheeuM8ejDafiN8CccY-0D4krAdYbuDU50zceb8gbDdC2E7Spvwx0vX_UmKDSmW1-e8GP-y78eRs9MK9s4R1ogUHVwIW4B1eJHYR8Kau2ZGyeYXUm2A1Cu4EL4CUm8IW2QfUq9y5y6YthFOQtvsep1wtS7GgDy78tvoq_MN44-7fB1c8hIJ3xK-pIQvS57zgd47nxtn4bXoDAJh9YWwGqSw1kXoEPSpN1rqaJ5Bij4mjwq0BQFGnDol4EnHI1h3M04V7kUyEUKPUu81qhEDAAAFUq_hf8nesPLnf6Tafpya_ADrIub301EbhJC6EHVMUdsDaBvdG3-89B5D0M7CET3-HrYjiXr9IZGS8CW756EtaBuisFGLmMG6PYyRc-daLDma9s7njZBR87W2MS_JavD4T8IQUb0jWv4n-T_Ypj-Hm1NOq3u8t42oUBrhv4v5pcnNaPn8Hu33e6HDg7bh4VAv7lFfP9nXXHfPcBYmfRngt6HLrzPwuEePVj4Ai2GND4nU90Rup-aN0OOU4lPHKd_8Os8HKtinuLL5T27VJ-Gttofhgn07EDyGTDzZFFABqVbTv8b2dCx0tXmQc-Kxro57-ytiessxCKuAjjoGDmjRi4hqNs561YEeY_IWVSZD3ymkiWq5WvCFmGBLa9ZU88W8XEyOLeeNVA02c1k3imKhGJvXuJcosK5rSSe6ZQUraUELWtKyWMxq1qiaVlgVHa_KpiNlgSehzcyY8ymrzIkOIWFLKW3KYmJEhyYMOpYxi08wWAljWdb6NjtNu3QIpCyMDjG8LRN1NNhuB9LOQgqYS9ILL04Y0eeCXS8kl2LQCmGfrBzqkwXyJHnTvpPCOh5TN5PuRNgux7m-pr13f6OMhO0GdGEQyQP8c8v-DQAA___C7DGz">