replaced dynamic_ by static_cast; typechecking done before

fixes Coverity 1223050