Union of structs with common first member

后端 未结 3 949
醉话见心
醉话见心 2020-12-18 07:59

I am unsure of whether or not the code has pointer aliasing (or other standard conformance issues) in the asserts cast. It seems that a pointer to the union type should be a

3条回答
  •  Happy的楠姐
    2020-12-18 08:39

    union don't pad, they just overlay their members. The first member of any struct is guaranteed to start right off, without padding. In general struct that start with the same members of same type are guaranteed to have the same layout for that initial part.

提交回复
热议问题