The correct thing should be to drop the piano on the compiler writers who, given
T *p;
, are unwilling to regard
*(U*)p=whatever;
as being a potential access to things of type
T
or
U
, but would instead insist that programmers use
memcpy
, which compilers must treat as a potential access to things of every type even when the programmer knows the pointer will never identify anything that isn't a
T
or
U
. I don't know why compiler writers decided they could make the world a better place if they force programmers to write code which is harder to read and less optimizable, but they did. —
supercat 7 secs ago