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

    <tr>
        <th>Summary</th>
        <td>
            [clang] Inconsistent (stateful) compilation of class template default member initializer from parenthesized aggregate initialization
        </td>
    </tr>

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

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

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

<pre>
    Since 16.0.0 and on trunk 0acb639fd2350d831f149035e078654a655c209b:

```c++
template<int I> struct S { int x, y, z = I; };
constexpr S<7> s1(1, 2);
using _ = decltype(S<7>{});
constexpr S<7> s2(3, 4);
static_assert(s1.z == s2.z);
```
fails with: 
```
<source>:6:15: error: static assertion failed due to requirement 's1.z == s2.z'
static_assert(s1.z == s2.z);
              ^~~~~~~~~~~~
<source>:6:20: note: expression evaluates to '0 == 7'
static_assert(s1.z == s2.z);
 ~~~~~^~~~~~~
```

Condensed to a single evaluation:
```c++
template<int I> struct S { int x, y, z = I; };
static_assert(S<7>(1, 2).z == S<S<7>{}.z>(3, 4).z);
```
```
<source>:8:15: error: static assertion failed due to requirement 'S<7>((1, 2, /*implicit*/(int)0)).z == S<7>((3, 4, )).z'
static_assert(S<7>(1, 2).z == S<S<7>{}.z>(3, 4).z);
 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<source>:8:28: note: expression evaluates to '0 == 7'
static_assert(S<7>(1, 2).z == S<S<7>{}.z>(3, 4).z);
              ~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
```

My guess would be that the default member initializer is lazy initialized in templates but this is not provoked by parenthesized aggregate initialization.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJy0Vctu47gS_Rp6U2iBIvVcaOFHG-jFXeUDGpRYknmbIjUklW57Md8-oBw_komDeWQIgVHoqlPnlE-Zwns1GMSG5B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