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

    <tr>
        <th>Summary</th>
        <td>
            [Clang] consteval functions called in NSDMI during aggregate initialization rejected if they use `this`
        </td>
    </tr>

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

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

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

<pre>
    Similar to https://eel.is/c++draft/expr.const#example-9

https://godbolt.org/z/zY3x1foG7

```c++
consteval int id(int i) { return i; }

struct A {
  int x;
  int y = id(x);
} a{42};
```

Clang rejects this:

```
<source>:5:11: error: call to consteval function 'id' is not a constant expression
    5 |   int y = id(x);
      | ^
<source>:6:7: note: in the default initializer of 'y'
    6 | } a{42};
      |       ^
<source>:5:3: note: declared here
    5 | int y = id(x);
      |   ^
<source>:5:14: note: implicit use of 'this' pointer is only allowed within the evaluation of a call to a 'constexpr' member function
    5 |   int y = id(x);
      | ^
```

MSVC also rejects this but GCC does not.

Clang *does* accept `a{ 42, id(a.x) }`
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJykVE1v4zYQ_TWjyyAGReojOugg2-tFD-klQIEeKWkssaVJg6Sy9v76gpI2jrduUGAN26L48eY9vpmR3qvBENWQbyHfJ3IKo3X1iwpSN360fyet7a_1qzopLR0Gi2MIZw-iAX4AfiDSG-WBHzrgW-Db3sljiPOXs9t01vgAXNBFns6anipge2DN8n-PM9i-tTpsrBuAH77H35_ikh7t1_LjISjY8l3DLbNzHHqTGpUJqHrgz_MAeIVQbtFRmJxBBWKLUO4_Avrgpi5gE_ctMziDXEDcvV8RxH6BvgCv3leh3KOEcpvxCPw--4Pmx1A7Lc2Ajv6iLngMo5rVPxK3voqdt5PrCMQXEE0OoklTEA2Sc9bFQSe1jpbc9B8n0wVlDQIvI9kSlUdjA8plkzQBozXkvbLmh0DEHKHc4edScf7EfZB_eUixANGUkZixgeJTGQwjYU9HOemAyqigpFbfyaE9Ro5X4OUNvVjQH17pLfo6-g8O8ZrERw49dVo66nEkRz8r_n96P4-WZneST2etOhVw8rSKnK3mJZ6tMoFctMQafUWptf1GPX5TYVxvKpo4ydlBe4ymrQ7LiLPYfDm7CHaiU0vu3fBft_JRyr68_rFDqb29S1tsp4BfdzvsLc3Ztfl3mgNv4irwBmXX0TkgFCy6ihkHvls4yc1lKdE9FCzpa9FXopIJ1WnJszTLs7RIxlpy1nZVXqSizLKOtULmbXksZJbysu04S1TNGc_YM2esSou82BCxtBJpmrGsKkWaQcboJJXeaP12ii0mUd5PVKcsq9hzomVL2s8dkPMu0gfOYzN0dTzw1E6Dh4xp5YO_QQQV9Nw2Z8GQ7x-UoZ8NpD4Wwu-v-5ffsJ-cMgPKYXA0yEC3mlhcX-45njjGhLjOaQQFm3OoYMnkdP1T51RhnNpNZ0_AD5Hd-ng6OxuxgB9mtbFJr4Lfav5PAAAA__-GDrYK">