Can a struct alias its own initial and only member?
问题 For example, is this code valid, or does it invoke undefined behavior by violating the aliasing rules? int x; struct s { int i; } y; x = 1; y = *(struct s *)&x; printf("%d\n", y.i); My interest is in using a technique based on this to develop a portable method for performing aliased reads. Update: here is the intended usage case, a little bit different, but it should be valid if and only if the above is valid: static inline uint32_t read32(const unsigned char *p) { struct a { char r[4]; };