Move a use of castPtr