<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/156996>156996</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
warn_cstruct_memaccess should not trigger inside constructors for otherwise trivially initializable types
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
ojhunt
</td>
</tr>
</table>
<pre>
We warn on this code, and variations of it, when gcc does not
```cpp
struct Object {
int some_field;
Object() { memset(this, 0, sizeof(*this); }
Object(const Object&);
};
```
I put together a general set of the cases at https://godbolt.org/z/5YYj1oxf9
Basically performing these operations within constructors of a type, as long as the reason for the type not being `trivially_{whatever}` is just its own constructors, not due to the object being polymorphic or some sub- or baseobject being non-trivial to copy or initialize.
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJxcU0GPszgM_TXhYk0VoEA5cJjup0p72uPqO40CMZBRiFFs2u38-lVgNKP5pKhpnMfzs19smN0UEDtVXVX1KzObzBQ7ep-3IFlP9tn9i_AwMQAFkNkxDGRRFX-BCRbuJjojjgIDjeAkxR8zBpiGASwhQyBR-jWtWh9rWFelXwFY4jYI_NO_4yCgmuseBRcEmBZ8Gx16q8o9fIBUcVFFm6Cw4MKYAklSyqrTD7sPpHGHvR4XrSqvoJpfB_cXzUCB5etYH7iESdD935fcQ_3fsG4CQhPKjBEMTBgwGg-MkkqXGWEwjAxGYBZZWZWvqrip4jaR7cnLieKkituHKm7V79_vOf03tgf31bAbjPdPWDGOFBcXpkTICLRi_Ozvw8nsAuzKU-Mo7j03IM_18IPBU5jSntRENEwBRor7MaGSGdBjole1lujuLqV9U831MRvBO8ZUf63BMbxvLOCEgR4_s6ZcichuCEI7OR0eHtQr-edCcZ3dABR3L4G3_iUdesP4AxwovHwKSWQDrc-Ec8GJM9594CmzXWnbsjUZdnlTNbo8N-0lmztb2bbVfWPsaM1oxirXFpvLuUTUZTU2mesKXVS61ZXO8zK_nMr8nA_9pdZtnRvd9-qscTHOn7y_L8mfzDFv2OVV3bZ15k2PnvfJKIqAD9hvVVGkQYld-uil3yZWZ-0dC3_TiBOPXZqat-Ho29uCixkGZAaeafN2b6FEN02YymVn8ae3yThKj-3hGOHLrO_WmN4ftnK2Rd_98eiczFt_GmhRxS3p-txe1kjHo7_t1bAqbp_l3rvi_wAAAP__L1pZGg">