added static cast to fix a clang compiler error under mac os x