On Sat, 28 Sep 2024, Jakub Jelinek wrote: > I'd hope that structure assignment is element-wise copying and so doesn't > need to preserve those bits. What about memcpy, or *(unsigned char *), > or for C++ std::bit_cast inspection of the bits (constexpr for C++ or not)?
In C, memcpy or *(unsigned char *) should allow the zeroed padding bits to be observed. Structure assignment does not need to preserve the bits. Assigning to any structure member after initialization also may change padding bits. (There was a proposal for more-defined evaluation order that was discussed at the WG14 meeting in Strasbourg in January - which received along-the-lines support but didn't come back in Minneapolis - that would have the effect of requiring initializer evaluations and stores in corresponding members in a particular order, effectively making automatic storage duration initializers more like a sequence of assignments. It didn't say anything about what the effects would be on padding bits.) -- Joseph S. Myers josmy...@redhat.com