Fix some maybe-unitialized warnings

This commit is contained in:
Christoph Hertzberg 2019-12-18 18:26:20 +01:00
parent 5a3eaf88ac
commit 72166d0e6e
2 changed files with 6 additions and 3 deletions

View File

@ -28,7 +28,7 @@ class AmbiVector
typedef typename NumTraits<Scalar>::Real RealScalar; typedef typename NumTraits<Scalar>::Real RealScalar;
explicit AmbiVector(Index size) explicit AmbiVector(Index size)
: m_buffer(0), m_zero(0), m_size(0), m_allocatedSize(0), m_allocatedElements(0), m_mode(-1) : m_buffer(0), m_zero(0), m_size(0), m_end(0), m_allocatedSize(0), m_allocatedElements(0), m_mode(-1)
{ {
resize(size); resize(size);
} }
@ -147,7 +147,8 @@ template<typename _Scalar,typename _StorageIndex>
void AmbiVector<_Scalar,_StorageIndex>::init(int mode) void AmbiVector<_Scalar,_StorageIndex>::init(int mode)
{ {
m_mode = mode; m_mode = mode;
if (m_mode==IsSparse) // This is only necessary in sparse mode, but we set these unconditionally to avoid some maybe-uninitialized warnings
// if (m_mode==IsSparse)
{ {
m_llSize = 0; m_llSize = 0;
m_llStart = -1; m_llStart = -1;

View File

@ -28,9 +28,11 @@
template<typename MatrixType> template<typename MatrixType>
void bdcsvd(const MatrixType& a = MatrixType(), bool pickrandom = true) void bdcsvd(const MatrixType& a = MatrixType(), bool pickrandom = true)
{ {
MatrixType m = a; MatrixType m;
if(pickrandom) if(pickrandom)
svd_fill_random(m); svd_fill_random(m);
else
m = a;
CALL_SUBTEST(( svd_test_all_computation_options<BDCSVD<MatrixType> >(m, false) )); CALL_SUBTEST(( svd_test_all_computation_options<BDCSVD<MatrixType> >(m, false) ));
} }