<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/56814>56814</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Defaulted default union constructor incorrectly deleted
</td>
</tr>
<tr>
<th>Labels</th>
<td>
clang:frontend
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
kparzysz-quic
</td>
</tr>
</table>
<pre>
```
struct NT {
NT(); // non-trivial constructor
};
union U {
U() = default;
NT x;
int y = 0; // default member initializer
};
```
```
$ clang++ -c union1.cc -std=c++17
union1.cc:6:3: warning: explicitly defaulted default constructor is implicitly deleted [-Wdefaulted-function-deleted]
U() = default;
^
union1.cc:7:6: note: default constructor of 'U' is implicitly deleted because variant field 'x' has a non-trivial default constructor
NT x;
^
1 warning generated.
```
This seems to contravene 15.1.5:
15.1 Constructors
[...]
A defaulted default constructor for class X is defined as deleted if:
- X is a union that has a variant member with a non-trivial default constructor and no variant member of X has a default member initializer,
[...]
This issue may be related to https://github.com/llvm/llvm-project/issues/56313.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJylVE1zmzAQ_TXisgMDkgH7wMGO22NPyTRXIYRRK4QrCSfOr-_yYcdOnKQznZGMPt7uvn27ctlVx4Jk8TziLYnXztteePhxDyTfTEeAO0KXhK4I2wCh33GA6UzorToorkF0ZjLr7GRB8i1C5_X42xvVGXi4dPow-QTCtlDJmvfan42GkPB8sVXGw3GExgOJE4vZDlrZltIiSnkkpF7kLSLXid4-pAsQmpsdoRscEAoYmSeREACh8xVSENNlkl-kNgAIW2c4GU544tYodINL-bzXSiivjye6sjoTv5AOlAPVXmC1HJAk3YQ_z4Zh3RvhMWA435N0-2-CkvTbe775zBnL6eXwvcWrq1HuHL3nH1AspeC9k3DgVnEsVK2krgab58Gm4Q74Vb_cCPJB2eGCd3ISFXbSSMsxcvRJZe8bJOukbB34bgjlLT-gISRplEQpJnuJHg7h7pWPmy_TTRRFZ43XX1Swxont4xw8DlIhRBmEcneWStXnwOEE4lOHgW-4n7U66Th39ZPyzdcKAjcVYt4aY_EeZ7efPBZ6d_UorrN-p6pyrpfQ8iNWHqzUQykGkRvv927Ib3ycO6Tdl5HoWtxofTh9wr3tfknhcTs6crhIM5awKJBFkqWrhMU0y4OqYNWKrXjgsdlksX2n_KTb1QsyorMWfb82Z9BbXfwPsWWyCJqiYoLJvMzrRSxyEdPlapmt8qQqGU-zisaB5qXUrkDpCKXTXwhb1xbbTpoKj1DNQBU0pjTO6YomLInziFU5r5M6XnKayozGZBHLlisdDXSizu4CW4zMyn7n8FIr593rJTaa2hkpx6jon_e-6Wzxe8_ty9G9hH96JYIxlWLM4y9u_tRF">