<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/81774>81774</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Clang incorrectly rejects default construction of union with nontrivial member, part 2
</td>
</tr>
<tr>
<th>Labels</th>
<td>
clang
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
StephanTLavavej
</td>
</tr>
</table>
<pre>
Accepted by VS 2022 17.10 Preview 1, rejected by Clang 17.0.3.
On Compiler Explorer, accepted by GCC 13.2, rejected by Clang 17.0.1 and trunk: https://godbolt.org/z/8fGhWa1ss
Presumably related to #48416 which was previously reported and fixed, but this larger repro is still failing.
```
C:\Temp>type meow.cpp
```
```cpp
enum class BasicFormatArgType { NoType, CustomType };
struct Monostate {};
struct Handle {
Handle(int, int) {}
};
template <typename Context>
struct BasicFormatArg {
BasicFormatArg() = default;
BasicFormatArg(int x, int y) : ActiveState(BasicFormatArgType::CustomType), CustomState(x, y) {}
BasicFormatArgType ActiveState = BasicFormatArgType::NoType;
union {
Monostate NoState = Monostate{};
Handle CustomState;
};
};
int main() {
BasicFormatArg<double> arg{};
(void) arg;
}
```
```
C:\Temp>cl /EHsc /nologo /W4 /std:c++latest /c meow.cpp
meow.cpp
C:\Temp>clang-cl -v
clang version 17.0.3
Target: x86_64-pc-windows-msvc
Thread model: posix
InstalledDir: C:\Program Files\Microsoft Visual Studio\2022\Preview\VC\Tools\Llvm\x64\bin
C:\Temp>clang-cl /EHsc /nologo /W4 /std:c++latest /c meow.cpp
meow.cpp(24,28): error: call to implicitly-deleted default constructor of 'BasicFormatArg<double>'
24 | BasicFormatArg<double> arg{};
| ^ ~~
meow.cpp(11,5): note: explicitly defaulted function was implicitly deleted here
11 | BasicFormatArg() = default;
| ^
meow.cpp(19,16): note: default constructor of 'BasicFormatArg<double>' is implicitly deleted because field 'CustomState'
has no default constructor
19 | Handle CustomState;
| ^
1 error generated.
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJysVk9v27gT_TT0ZWBDomTJPvjgKHH7A9r-CiRojwuKGtvsUqRAUo69h372xUhy_DfdYrFBYNnkcN57M8PRCO_VxiAu2PSBTR9Hog1b6xbPAZutMC-fxE7s8MeotNVhsZQSm4AVlAf49gw84hzifBJH8NXhTuErxIwX4PAHysGs0MJsyCiaJBMWPbJo2X_-30Bh60ZpdPC0b7R16OiwOMP4UBQQJxP-C6cxCFNBcK35kyVL2IbQeJYsGV8xvtrYqrQ6TKzbML76i_HVbP1h-13E3p9T-erQt7Uo9QEcakEgwQLjSTpL4wxet0pu4VV4aEilbX1n2FhHlgS_VnusiGTZBghb5UELt0FHVs6C8uCD0hrWQmllNhdxYFk0_Hc_CyI_LV6wbljyFA4NQo32dSKb5q792883AzRtDVIL7-FBeCVX1tUiLN3mhZyx_AG-WPpKfIvWB1sPG48seThn5oNrZYDP1lgfROjOvmv1UZhK9ybdMgAMa4zPlAmE1j3mRze9jxt_AetGd2hJQfKNqBEKawLuA0ueLkAv9V2CX-4xPuugk0eocC1aHa5g7x5RJsB-YA6H3sESljKoHT5TSBif3caYMpgsT6FlfH6K9fFY5_ZwE46ey528nYF2Kt6DHXJ7K641yprLENHfKbtf7Mn72-pVyo-nhmyfSzo3ucjqTYYpmLVQ5piTN0pX8U-KyralRpY8gXCbO1QYn-2sqsgLGZxD_vKu3LtqUgPjq6ePXtLTWG031ANW31P69KFiyVIy_sD4A5WnD7Qsry7n1VW9CyPMZiw1jHf9drcAO3Se8tM3yn7nhXpIoIrbz7I_snTcyPGrMpV99ePa7-RgtXUoKqhthZpsG-vVvt_6n_FBaI3Vo3K0NTD56uzGiRpWSqNn0-Kzks56uw7wTflWaHgObaUsmxbU4LsDXXNn0-JbQUqs1XTuk97VbFrss5RNi1KZ3xD9H0aYz3jKeNHVEIlD52ynUgqtqX-rutFKqqAP4wo1Uq8erj5Ia_oOYh3YNTCev196jOdDwfEUWF7AnU7xz5UK3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