diff --git a/Eigen/src/Core/Eval.h b/Eigen/src/Core/Eval.h index efa68a7cb..7fa661c48 100644 --- a/Eigen/src/Core/Eval.h +++ b/Eigen/src/Core/Eval.h @@ -56,7 +56,6 @@ template class Eval : NoOperatorEquals, typedef Expression Base; friend class MatrixBase; - Eval() : MatrixType() {} Eval(const Expression& expression) : MatrixType(expression) {} }; diff --git a/Eigen/src/Core/Matrix.h b/Eigen/src/Core/Matrix.h index a829a2f8f..0165d5a7d 100644 --- a/Eigen/src/Core/Matrix.h +++ b/Eigen/src/Core/Matrix.h @@ -163,13 +163,14 @@ class Matrix : public MatrixBase<_Scalar, Matrix<_Scalar, _Rows, _Cols, _Storage static Map map(Scalar* array, int size); static Map map(Scalar* array); - /** Default constructor. - * - * For fixed-size matrices, does nothing. - * - * For dynamic-size matrices, dynamic dimensions are set to 1. + /** Default constructor, does nothing. Only for fixed-size matrices. + * For dynamic-size matrices and vectors, this constructor is forbidden (guarded by + * an assertion) because it would leave the matrix without an allocated data buffer. */ - explicit Matrix() : Storage() {} + explicit Matrix() : Storage() + { + assert(RowsAtCompileTime > 0 && ColsAtCompileTime > 0); + } /** Constructs a vector or row-vector with given dimension. \only_for_vectors * diff --git a/Eigen/src/Core/MatrixStorage.h b/Eigen/src/Core/MatrixStorage.h index db4feb195..ebeaf4922 100644 --- a/Eigen/src/Core/MatrixStorage.h +++ b/Eigen/src/Core/MatrixStorage.h @@ -80,7 +80,7 @@ class MatrixStorage { return ColsAtCompileTime; } public: - MatrixStorage(int dim = 1) : m_rows(dim) + MatrixStorage(int dim) : m_rows(dim) { m_data = new Scalar[m_rows * ColsAtCompileTime]; } @@ -92,6 +92,9 @@ class MatrixStorage ~MatrixStorage() { delete[] m_data; } + + private: + MatrixStorage(); }; template @@ -120,7 +123,7 @@ class MatrixStorage { return m_cols; } public: - MatrixStorage(int dim = 1) : m_cols(dim) + MatrixStorage(int dim) : m_cols(dim) { m_data = new Scalar[m_cols * RowsAtCompileTime]; } @@ -132,6 +135,9 @@ class MatrixStorage ~MatrixStorage() { delete[] m_data; } + + private: + MatrixStorage(); }; template @@ -161,13 +167,17 @@ class MatrixStorage public: - MatrixStorage(int rows = 1, int cols = 1) : m_rows(rows), m_cols(cols) + MatrixStorage(int rows, int cols) : m_rows(rows), m_cols(cols) { m_data = new Scalar[m_rows * m_cols]; } ~MatrixStorage() { delete[] m_data; } + + private: + MatrixStorage(); + MatrixStorage(int dim); }; #endif // EIGEN_MATRIXSTORAGE_H