From 9d7843d0d0879a5c22741f19aaab7ad116bd352e Mon Sep 17 00:00:00 2001 From: Christoph Hertzberg Date: Thu, 16 Apr 2015 15:47:06 +0200 Subject: Add internal assertions to DenseStorage constructor --- Eigen/src/Core/DenseStorage.h | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) (limited to 'Eigen/src/Core/DenseStorage.h') diff --git a/Eigen/src/Core/DenseStorage.h b/Eigen/src/Core/DenseStorage.h index 8fcc83a5a..37759a585 100644 --- a/Eigen/src/Core/DenseStorage.h +++ b/Eigen/src/Core/DenseStorage.h @@ -358,7 +358,12 @@ template class DenseStorage(size)), m_rows(nbRows), m_cols(nbCols) - { EIGEN_INTERNAL_DENSE_STORAGE_CTOR_PLUGIN } + { + EIGEN_INTERNAL_DENSE_STORAGE_CTOR_PLUGIN + eigen_internal_assert(size==nbRows*nbCols && nbRows>=0 && nbCols >=0); + EIGEN_ONLY_USED_FOR_DEBUG(nbRows); + EIGEN_ONLY_USED_FOR_DEBUG(nbCols); + } DenseStorage(const DenseStorage& other) : m_data(internal::conditional_aligned_new_auto(other.m_rows*other.m_cols)) , m_rows(other.m_rows) @@ -433,8 +438,12 @@ template class DenseStorage(size)), m_cols(nbCols) - { EIGEN_INTERNAL_DENSE_STORAGE_CTOR_PLUGIN } + DenseStorage(Index size, Index nbRows, Index nbCols) : m_data(internal::conditional_aligned_new_auto(size)), m_cols(nbCols) + { + EIGEN_INTERNAL_DENSE_STORAGE_CTOR_PLUGIN + eigen_internal_assert(size==nbRows*nbCols && nbRows==_Rows && nbCols >=0); + EIGEN_ONLY_USED_FOR_DEBUG(nbRows); + } DenseStorage(const DenseStorage& other) : m_data(internal::conditional_aligned_new_auto(_Rows*other.m_cols)) , m_cols(other.m_cols) @@ -502,8 +511,12 @@ template class DenseStorage(size)), m_rows(nbRows) - { EIGEN_INTERNAL_DENSE_STORAGE_CTOR_PLUGIN } + DenseStorage(Index size, Index nbRows, Index nbCols) : m_data(internal::conditional_aligned_new_auto(size)), m_rows(nbRows) + { + EIGEN_INTERNAL_DENSE_STORAGE_CTOR_PLUGIN + eigen_internal_assert(size==nbRows*nbCols && nbRows>=0 && nbCols == _Cols); + EIGEN_ONLY_USED_FOR_DEBUG(nbCols); + } DenseStorage(const DenseStorage& other) : m_data(internal::conditional_aligned_new_auto(other.m_rows*_Cols)) , m_rows(other.m_rows) -- cgit v1.2.3