AMDG Ovanes Markarian wrote:
Yes I read the paragraph as well. But as far as I understand my use case is legal (assumed uint64_t is POD), which I think it is. Or am I mistaken?
It's legal for char or unsigned char to alias any type, so it would probably actually be okay in this specific case.
This is what 9.2 Clause 16 states (you have a snippet from 9.5 which just refers to that one): "If a POD-union contains two or more POD-structs that share a common initial sequence, and if the PODunion object currently contains one of these POD-structs, it is permitted to inspect the common initial part of any of them. Two POD-structs share a common initial sequence if corresponding members have layoutcompatible types (and, for bit-fields, the same widths) for a sequence of one or more initial members."
I understand that that it is allowed to use union for byte conversions of POD types.
"Common initial sequence" means something like struct { int x; double y; }; struct { int x; float y; }; int x is common to the two structs. You can't use a union to convert between arbitrary PODs. In Christ, Steven Watanabe