This was a bug and has since been fixed, so the solution is simply to update your compiler. If there is some reason you can't (company required version, etc) then your cast() is sadly probably the only way.