diff --git a/include/eigenpy/numpy-allocator.hpp b/include/eigenpy/numpy-allocator.hpp
index 3382eb32ab9d68a988f530c085c0907368351969..026f65bc0f72f0bf5a15fab5759b5b467ca8b72b 100644
--- a/include/eigenpy/numpy-allocator.hpp
+++ b/include/eigenpy/numpy-allocator.hpp
@@ -250,7 +250,10 @@ struct numpy_allocator_impl_tensor<Eigen::TensorRef<TensorType> > {
 
       return pyArray;
     } else {
-      return NumpyAllocator<TensorType>::allocate(tensor, nd, shape);
+      return NumpyAllocator<TensorType>::allocate(
+          static_cast<Eigen::TensorBase<Eigen::TensorRef<TensorType> > &>(
+              tensor),
+          nd, shape);
     }
   }
 };
@@ -278,7 +281,11 @@ struct numpy_allocator_impl_tensor<const Eigen::TensorRef<const TensorType> > {
 
       return pyArray;
     } else {
-      return NumpyAllocator<TensorType>::allocate(tensor, nd, shape);
+      return NumpyAllocator<TensorType>::allocate(
+          static_cast<
+              const Eigen::TensorBase<Eigen::TensorRef<const TensorType> > &>(
+              tensor),
+          nd, shape);
     }
   }
 };