Fix type aliasing issue reported by gcc.

Fixes boost trac ticket #9550.