diff --git a/include/eigenpy/user-type.hpp b/include/eigenpy/user-type.hpp
index 53d08decc025fa1d44f89a13a779eb612f344b39..31ccdebaaa747384cfd7da82a3ccd9c1078b042c 100644
--- a/include/eigenpy/user-type.hpp
+++ b/include/eigenpy/user-type.hpp
@@ -194,8 +194,9 @@ namespace eigenpy
       inline static int fillwithscalar(void* buffer_, npy_intp length,
                                        void* value, void* /*arr*/)
       {
-        T r = *(T*)value;
-        T* buffer = (T*)buffer_;
+//        std::cout << "fillwithscalar" << std::endl;
+        T r = *static_cast<T*>(value);
+        T* buffer = static_cast<T*>(buffer_);
         npy_intp i;
         for (i = 0; i < length; i++) {
           buffer[i] = r;