union for uint32_t and uint8_t[4] undefined behavior? [duplicate]
问题 This question already has answers here : Purpose of Unions in C and C++ (15 answers) Closed 5 years ago . In the comments of this answer it is said that it would be undefined behavior to split up an integer into their bytes using a union like follows. The code given at that place is similar though not identical to this, please give a note if have I changed undefined-behavior-relevant aspects of the code. union addr { uint8_t addr8[4]; uint32_t addr32; }; Up to now I thought this would be a