Add an explicit cast to avoid warnings.  Fixes #8779.