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

    <tr>
        <th>Summary</th>
        <td>
            [consteval] Initializing a field with a lambda taking a consteval argument makes the constructor consteval
        </td>
    </tr>

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

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

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

<pre>
    Reproduction:

```cpp
inline consteval int foo() { return 1; }

struct D {
  // User-defined, non-constexpr constructor.
  D(){}
};
struct F {
  const D d;
  int e{[](int r)  {
    return r;
  }(foo())};
};

F f;
```

Error:
```
<source>:14:3: error: call to immediate function 'F::F' is not a constant expression
   14 | F f;
      | ^
<source>:7:8: note: 'F' is an immediate constructor because the default initializer of 'e' contains a call to a consteval function 'foo' and that call is not a constant expression
    7 | struct F {
      | ^
<source>:14:3: note: non-constexpr constructor 'F' cannot be used in a constant expression
   14 | F f;
      |   ^
<source>:7:8: note: declared here
    7 | struct F {
      |        ^
1 error generated.
Compiler returned: 1
```

On clang trunk: https://godbolt.org/z/zrMo5jvqx

GCC and MSVC accept it.

I think it's not true that the call to 'foo' is not a constant expression? I don't have a paragraph from the standard to quote, though.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJykVU2P4zYM_TXKhZjAlp04PuSQScbFHBYFWrR32mJs7ciSV6Kz0_31hex8eBfb7RY1EjugST4-8jHCEHRrifZi8yw2pxWO3Dm_t5otGbzQqnbqr_1vNHinxoa1syI7iOQkktt9m8yfZhhmi7ZGW4LG2cB0QQPaMpydE3InZAmieAZPPHoLqcieQRSnZb7AfmwYTtFvtgAIWQlZwR-B_JOis7akhDyCdfZpRnkf_IwXY51f3wJPM2ZMdUcpTiJ7_gqrWmJNaeAE6u4FEwGKPlOPhNxFg49klpFwo-UXoRFO7u7sp2IeBXz1e7pXcH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