<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/54259>54259</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Missing warning when constexpr constructor of template class initializes only in ctor body
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
Magnutic
</td>
</tr>
</table>
<pre>
Discovered in Ubuntu clang version 11.0.0-2~ubuntu20.04.1, reproduced in trunk on Godbolt: https://gcc.godbolt.org/z/n1jbK6b3o
Example:
```
template <typename = int> // Commenting this line causes a warning
struct Test {
constexpr Test(int a_) {
a = a_; // Commenting this line results in an error
}
int a;
};
constexpr Test t(1);
```
If the first line is removed, a `-Wc++20-extensions` warning is emitted. The warning should probably not be dependent on whether the class is a template or not.
There was a similar issue here: https://github.com/llvm/llvm-project/issues/34659
But the difference is that in this issue, the member variable is initialized, only not in the member-initialization-list.
Possibly related: https://github.com/llvm/llvm-project/issues/46689
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJylVMlu2zAQ_RrqQliQKFu2DjrEcVIURYAeWvRYkOLYYkqRBpdsX98hZccxUPTQCrJMcrY3740krHztd8oP9gkcSKoM_S6iCZEOmpsDxVOvrKF1XVZltWBkfRezneF2WdaE3VIHR2dlHObw4KL5RTHkk5XC6kCaGzqGcPS4IOwe78MwlIfZWFp3wJM3_Jn6UXxpRWNJtSPVzfy8e-HTUUMK_XBK2up0520A9OEBKGluw-sRDJ_SeodosPodnavSWztNYILCrsKoPNXKAB149OApp8_cGTTNGT02MQT6DXygZL2dDylegzU-wMvRZRthGyxB-U_Cumu_dPGMAY3N9q8QHPiog0_ccUPBOesuich6d9nkYpjuxAKazutrXDQhQ2m6i-81Y_Pz8x5RAN0rhyEZCkJyMOEoyKQrNtBWix8DYVu8WbWAlwAmjYNHw5mxFASTCgFkSb9hvvO5H23UkuJsCC70KzU2UAFUAiokkYU0I88jIASXceDAeZ-ycfquqHUprPyIGku4VCT5eTUpzR0G-Qg0Gf4wbSqMUZSDnXCj9dP5b4HAHmFAqu5zuMdFs2xX3VxmG0NGJdV-j3nNkNkJIw95yJN6OSwRlfwmmAQ28sSdwm6zszIqKK7V20ynNScScvw5YvHuxQMyu9DKX_f71XqvEn8OEiXy_zpctu2mK2TfyK7peBFU0NA_oDkpdlYOVTEfRj2v0guBatj9RZyTYO9d-rlFbC-7Cvy0FNHp_t_RrpZs1RVjX0PbikoIqNtNs-LANnItZAc4WN0gqrrQXID2PVnhpDIDz2dtGFntCtWzirGqqdasXrasK9uuaTa8lbJrNxzqjiwrmLjSZcKRPkmF6zMkEQ8ejUkTfzFi1-pgAHI5zM9jGK3rH_jBxKCGItfuM_bfUJu6nA">