<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/64843>64843</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Improve error message for `constexpr` constructors of virtual base classes
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
Eisenwave
</td>
</tr>
</table>
<pre>
## Code to Reproduce (https://godbolt.org/z/6EhPfTTfE)
```cpp
struct Base {
constexpr Base() = default;
};
struct Derived : virtual Base {
constexpr Derived() = default;
};
```
Clang diagnostic:
```none
<source>:5:3: error: defaulted definition of default constructor is not constexpr
5 | constexpr Derived() = default;
| ^
```
GCC diagnostic:
```none
<source>:5:13: error: explicitly defaulted function 'constexpr Derived::Derived()' cannot be declared 'constexpr' because the implicit declaration is not 'constexpr':
5 | constexpr Derived() = default;
| ^~~~~~~
```
MSVC diagnostic:
```none
<source>(5): error C2468: constructor cannot be 'constexpr' in a class or struct with virtual base classes
<source>(6): note: see reference to function 'Derived::Derived(void)'
```
## Suggested Resolution
Out of the three, the MSVC diagnostic seems best. It would be nice if clang could output something similar.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJysVUuP2zYQ_jXjyyCGTFqyfNDB60eRQ9EiCXqnqJHEgiIFPrxJD_3tBSWt17t1izYIIUDkaDgz3zcPCe9VZ4gqyJ8gP61EDL111Vl5Ms_iSqvaNt8qYBwYx6NtCIPFTzQ620RJCKzsQxg98AOwC7BLZ5va6rC2rgN2-QPYpTj3v7ZfvrRnYHvITpAdoMjmR47jLPHBRRnwSXhC2D3NQkRpjQ_0dXTTF2AlsD0CP2FDrYg6AF9UYXe67RdbJ3LqSg0CP-BVuRCF_hf7i_Z_dHEDMB-PWpgOGyU6Y31QMpHxVs9YQ4uIH72NThLwM_BDDvzAU4jknHVps_ilJu2UUUFZg7Z9kc8xJ4TWofJobHiF8YILMUfYHfH_IcRpzfcgPz-E-tPx-P1AN2-R0tdRK6mC_nYHuo1GTpCB7f4ePD8AP7xBAmyHUphEQ03YkNTCpazf3U4qNUkRPWHoCdUw-120xeRuofLdvRvAH8Hp64L8_Oe0HnL88-ffvotkVuaJkBeK8ci2RZmO9yXzytV7ipRBgVIL79E6XLroWYX-1j51ap9Jg_xD_8Xi39hA6e2J0FFLjoycBsd9dv8hp1ermjmvD8lZJtHn2HXkU8F8Im91TEZnhV9iSO2SEh16RwTsOB3esZpiGzzW5MMaPwZ8tlE3iRajJKFqE07ToZzENoYxBvR2oNAr06FXg9LCrVdNxZs934sVVZtiz_KiKBhb9VVTF8V-R82mbDes3JbbvM3Lcsta4kLs6mKlKpYxnpUsYxvGt2wtW8ZK3rJ2J_dtVm5gm9EglF5rfR3SOF0p7yNVxbbc8pUWNWk_DW3GDD3j9BEYSzPcVenOhzp2HraZVj74VytBBU3Vx2F09kpLpQzkvegIW-swjeVbWRTZffH4ROyjYlhFp6t3_wEV-livpR2AXZLz5fVhdPZ3kgHYZQrZpz9EgvRXAAAA__9G7wEM">