[HSA-680 Fix] Use casts since older gcc version do not handle casting by union correctly