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

    <tr>
        <th>Summary</th>
        <td>
            Constexpr lambda cannot be used without capturing 
        </td>
    </tr>

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

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

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

<pre>
    The following [valid](https://stackoverflow.com/questions/78085671/lambda-constexpr-works-in-msvc-but-not-in-gcc) program is rejected by clang and gcc. [Demo](https://godbolt.org/z/xhes5fvoc)

```
int main() {
 constexpr auto func = []()constexpr { return 1; };
    auto i = []{return func();};
}   
```
Clang says:

```
<source>:3:24: error: variable 'func' cannot be implicitly captured in a lambda with no capture-default specified
    3 |     auto i = []{return func();};
 |                        ^
<source>:2:20: note: 'func' declared here
 2 |     constexpr auto func = []()constexpr { return 1; };
      | ^
<source>:3:14: note: lambda expression begins here
    3 |     auto i = []{return func();};
      | ^
<source>:3:15: note: capture 'func' by value
    3 |     auto i = []{return func();};
      |               ^
      | func
<source>:3:15: note: capture 'func' by reference
    3 |     auto i = []{return func();};
      |               ^
      | &func
<source>:3:15: note: default capture by value
    3 |     auto i = []{return func();};
      |               ^
      | =
<source>:3:15: note: default capture by reference
    3 |     auto i = []{return func();};
      |               ^
      | &
```

Bug discovered first [here](https://stackoverflow.com/questions/78085671/lambda-constexpr-works-in-msvc-but-not-in-gcc)
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzEltGyojgTx5-muenCggQOesGFHscn-F4gJA3mm5C4SdBxn34riEdry1O1O7O7x1IQSf759b8l3SIEPViiFuod1PtMTPHofOuFFcI6d8o6p67t_46EvTPGXbQdEOrdWRitoN4DWx9jPAXgW2AHYIcQhfzuzuR74y4r6UZgh98mClE7G4AdmnWxrt-aEtjBiLFTIpfOhkg_Tj6_OP895NrmYzjLvJtibl1M14OUwDZ48m7wYkQd0NP_SUZS2F1RGmEHFFbhIOUq0e1pdK_gBqc6Z-LK-QHY4Xdghx9HCnV_dkkfij0U2-X4Vizv-VLbiKPQFtg6gUCzu_2OH_Aopuiwn6xE4Hu8uXkb_hgDzQ49xclbLIHvEJo98LsU4k1DPws0u2V8Ur7JpRlP86DZI-JL6vfZmCCuswOfRwf8PbjJSwL-DfiWA9-yCvgWyXvn05ez8Fp0hhBYcyNpUAprXcSOUI8no6WO5opSnOLkSaG2KPCWYbzoeETr7jdzRb2YTMRwIql7TerhAEdo3vFnvfiY_OIF9beX0bL0KVKQ1kVK56cYFUkjUjhH8rSswT5W-WeTj7PuZ5gpKWX1jLmYm7QpBO0sdjRoG55Zf93RvwZWP4MtaX72sbviWZjpX8D6JMmPAbPGr4B76smTlV8BD-ztb_Dfn6t7HF_oOvD9z0N_seOv98j5uJsGVDrIVOBIYa99iAljfuT-22qYqZarDd-IjNqyKTa8KNi6zI5tI5UUfa8KUlRLUfRVXauu7xsmqr4qKdMtK1hV8KIsOV8X5Ypk06-Jl7wqN1UpFFQFjUKblTHnMRXLTIcwUbvm9dsmM6IjE-Z-gTFLF5xvAmOpffBtmpN30xCgKowOMTxUoo6G2vePHXHZwR6FZAqk5mrhpvsfIvUb2eRN-6dKruNx6hZH0wLLKT95lzoDYIcZK5k8Y_8RAAD__86Wgeg">