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

    <tr>
        <th>Summary</th>
        <td>
            Clang rejects constexpr variable initialiation from constepxr function template parameter 
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            clang
      </td>
    </tr>

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

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

<pre>
    The following program is rejected by clang but accepted by gcc and msvc. [Demo](https://godbolt.org/z/95Pfrqrex)

```
template <typename T>
constexpr auto func(T c) {
    constexpr auto k = c(); 
 return k;
};


int main() {
    
    constexpr int i = 0;
    
    constexpr auto lambda = []()constexpr { constexpr int j = i; return j; };  //compiles
    constexpr auto lambda2 = [i]()constexpr { constexpr int j = i; return j; };//compiles
   
    constexpr auto a = func(lambda); //clang and others compiles this

    
    constexpr auto b = func(lambda2); //clang doesn't compile this
    

```
Clang says:

```
<source>:3:20: error: constexpr variable 'k' must be initialized by a constant expression
    3 |     constexpr auto k = c(); 
      |                    ^   ~~~
<source>:18:24: note: in instantiation of function template specialization 'func<(lambda at <source>:13:30)>' requested here
   18 |     constexpr auto b = func(lambda2); //clang doesn't compile this
      | ^
<source>:13:65: note: function parameter 'c' with unknown value cannot be used in a constant expression
   13 |     constexpr auto lambda2 = [i]()constexpr { constexpr int j = i; return j; };//compiles
      | ^
<source>:3:24: note: in call to 'c.operator()()'
    3 |     constexpr auto k = c(); 
 |                        ^~~
<source>:2:23: note: declared here
 2 | constexpr auto func(T c) {
      |                       ^
1 error generated.
Compiler returned: 1
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJy8VsuS46gS_Rq8yWiHBJYlLbTwo7y-i_oBhNI2VQjUgOrRi_r2G4D8aI_dPRM9MYoqCdtJnjyZJ1Nw5-RBIzakWJNiO-OjPxrbWK4518YMs9Z0n83zEWFvlDL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