<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/69890>69890</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Value initialization with implied zero-initialization does not occur for derived class
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
Fedr
</td>
</tr>
</table>
<pre>
This program
```
struct A {
constexpr A() {}
int x;
};
struct B : A {
int y;
};
static_assert( B().x == 0 );
```
shall be accepted because
1. `()` performs value-initialization on `B`: http://eel.is/c++draft/dcl.dcl#dcl.init.general-16.4
2. Since `B`'s ctor is not user-provided, that resolves to zero-initialization followed by default-initialization: http://eel.is/c++draft/dcl.dcl#dcl.init.general-9.1.2
3. Zero-initialization of `B` propagates to `A`, then propagates to `x` and zeroes it, regardless of `A` having a user-provided constructor or not: http://eel.is/c++draft/dcl.dcl#dcl.init.general-6.2
4. Lastly default-initialization of `B` calls `B`'s constructor and in turn calls `A`'s constructor.
Unfortunatly, only MSVC implemented zero-initialization in this scenario by now. Online demo: https://godbolt.org/z/YMv94rabv
GCC has a similar defect, see https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108993
Related discussion: https://stackoverflow.com/a/77273671/7325599
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJysVE2P4zYM_TXKhRjDlhMnOviQTOBeuijQbRdoLwtapm21ihSIcjIzv76Qk53JpLN7WiBAlJB85Hv8QGYzOKJarHZitV_gFEcf6oa6sGh991z_MRqGY_BDwIPI9yLfiiq_fuafHMOkI2xBrHeXf0B7x5GejgG2Qm6EVLNtvb-aAcC4CE-ivAYk0-v7FnQHoty-g77GPv8wFqPRX5GZQhRyA7tLEdkTiHIvyj3kIKR6i7rjM6K10BKg1nSM1EFLGiemi7nIILnOiKLK4Uih9-HAcEI70YNxJhq05gWj8Q68S967FFFuYYzxKMqtkI2QDZHNDAvZaCF3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