What are the aliasing rules for wchar_t with regards to its
underlying int type?
That the underlying type is an integer type, whose values can
represent distinct codes for all members of the largest extended
character set specified among the supported locales.
In practice, constraints of backwards compatibility mean that
some widespread implementations aren't strictly conformant in
regard to that last criteria---formally, it means that if any
supported locale supports modern versions of Unicode, wchar_t
must have at least 21 bits.
E.g., if wchar_t is 16-bits, is it safe to cast to uint16_t?
The results of the cast will be well defined on all systems, but
there's no guarantee that information won't be lost. wchar_t is
often 32 bits (and would almost certainly be 32 bits almost
everywhere without considerations of backwards compatibility,
which constraint Windows and AIX to 16 bit values).