Convert casts to unions, to fix alignment issues on Solaris