A question about union in C – store as one type and read as another – is it implementation defined?
This is undefined behaviour. u.i and u.ch are located at the same memory address. So, the result of writing into one and reading from the other depends on the compiler, platform, architecture, and sometimes even compiler’s optimization level. Therefore the output for u.i may not always be 515. Example For example gcc on my machine …