Fix strict aliasing violations.

(cherry picked from commit 6d19195845b6c81a6507e4a23d26746bb2c9f0f6)