Fix gcc 8.1 warning: "maybe use uninitialized"

This commit is contained in:
Gael Guennebaud 2018-10-07 21:54:49 +02:00
parent 6512c5e136
commit 16b2001ece
6 changed files with 36 additions and 36 deletions

View File

@ -18,7 +18,7 @@ void check_stddeque_matrix(const MatrixType& m)
Index rows = m.rows(); Index rows = m.rows();
Index cols = m.cols(); Index cols = m.cols();
MatrixType x = MatrixType::Random(rows,cols), y = MatrixType::Random(rows,cols); MatrixType x = MatrixType::Random(rows,cols), y = MatrixType::Random(rows,cols);
std::deque<MatrixType,Eigen::aligned_allocator<MatrixType> > v(10, MatrixType(rows,cols)), w(20, y); std::deque<MatrixType,Eigen::aligned_allocator<MatrixType> > v(10, MatrixType::Zero(rows,cols)), w(20, y);
v.front() = x; v.front() = x;
w.front() = w.back(); w.front() = w.back();
VERIFY_IS_APPROX(w.front(), w.back()); VERIFY_IS_APPROX(w.front(), w.back());
@ -33,7 +33,7 @@ void check_stddeque_matrix(const MatrixType& m)
++wi; ++wi;
} }
v.resize(21); v.resize(21,MatrixType::Zero(rows,cols));
v.back() = x; v.back() = x;
VERIFY_IS_APPROX(v.back(), x); VERIFY_IS_APPROX(v.back(), x);
v.resize(22,y); v.resize(22,y);
@ -46,8 +46,8 @@ template<typename TransformType>
void check_stddeque_transform(const TransformType&) void check_stddeque_transform(const TransformType&)
{ {
typedef typename TransformType::MatrixType MatrixType; typedef typename TransformType::MatrixType MatrixType;
TransformType x(MatrixType::Random()), y(MatrixType::Random()); TransformType x(MatrixType::Random()), y(MatrixType::Random()), ti=TransformType::Identity();
std::deque<TransformType,Eigen::aligned_allocator<TransformType> > v(10), w(20, y); std::deque<TransformType,Eigen::aligned_allocator<TransformType> > v(10,ti), w(20, y);
v.front() = x; v.front() = x;
w.front() = w.back(); w.front() = w.back();
VERIFY_IS_APPROX(w.front(), w.back()); VERIFY_IS_APPROX(w.front(), w.back());
@ -62,7 +62,7 @@ void check_stddeque_transform(const TransformType&)
++wi; ++wi;
} }
v.resize(21); v.resize(21,ti);
v.back() = x; v.back() = x;
VERIFY_IS_APPROX(v.back(), x); VERIFY_IS_APPROX(v.back(), x);
v.resize(22,y); v.resize(22,y);
@ -75,8 +75,8 @@ template<typename QuaternionType>
void check_stddeque_quaternion(const QuaternionType&) void check_stddeque_quaternion(const QuaternionType&)
{ {
typedef typename QuaternionType::Coefficients Coefficients; typedef typename QuaternionType::Coefficients Coefficients;
QuaternionType x(Coefficients::Random()), y(Coefficients::Random()); QuaternionType x(Coefficients::Random()), y(Coefficients::Random()), qi=QuaternionType::Identity();
std::deque<QuaternionType,Eigen::aligned_allocator<QuaternionType> > v(10), w(20, y); std::deque<QuaternionType,Eigen::aligned_allocator<QuaternionType> > v(10,qi), w(20, y);
v.front() = x; v.front() = x;
w.front() = w.back(); w.front() = w.back();
VERIFY_IS_APPROX(w.front(), w.back()); VERIFY_IS_APPROX(w.front(), w.back());
@ -91,7 +91,7 @@ void check_stddeque_quaternion(const QuaternionType&)
++wi; ++wi;
} }
v.resize(21); v.resize(21,qi);
v.back() = x; v.back() = x;
VERIFY_IS_APPROX(v.back(), x); VERIFY_IS_APPROX(v.back(), x);
v.resize(22,y); v.resize(22,y);

View File

@ -31,7 +31,7 @@ void check_stddeque_matrix(const MatrixType& m)
Index rows = m.rows(); Index rows = m.rows();
Index cols = m.cols(); Index cols = m.cols();
MatrixType x = MatrixType::Random(rows,cols), y = MatrixType::Random(rows,cols); MatrixType x = MatrixType::Random(rows,cols), y = MatrixType::Random(rows,cols);
std::deque<MatrixType> v(10, MatrixType(rows,cols)), w(20, y); std::deque<MatrixType> v(10, MatrixType::Zero(rows,cols)), w(20, y);
v[5] = x; v[5] = x;
w[6] = v[5]; w[6] = v[5];
VERIFY_IS_APPROX(w[6], v[5]); VERIFY_IS_APPROX(w[6], v[5]);
@ -64,8 +64,8 @@ template<typename TransformType>
void check_stddeque_transform(const TransformType&) void check_stddeque_transform(const TransformType&)
{ {
typedef typename TransformType::MatrixType MatrixType; typedef typename TransformType::MatrixType MatrixType;
TransformType x(MatrixType::Random()), y(MatrixType::Random()); TransformType x(MatrixType::Random()), y(MatrixType::Random()), ti=TransformType::Identity();
std::deque<TransformType> v(10), w(20, y); std::deque<TransformType> v(10,ti), w(20, y);
v[5] = x; v[5] = x;
w[6] = v[5]; w[6] = v[5];
VERIFY_IS_APPROX(w[6], v[5]); VERIFY_IS_APPROX(w[6], v[5]);
@ -75,7 +75,7 @@ void check_stddeque_transform(const TransformType&)
VERIFY_IS_APPROX(w[i], v[i]); VERIFY_IS_APPROX(w[i], v[i]);
} }
v.resize(21); v.resize(21,ti);
v[20] = x; v[20] = x;
VERIFY_IS_APPROX(v[20], x); VERIFY_IS_APPROX(v[20], x);
v.resize(22,y); v.resize(22,y);
@ -98,8 +98,8 @@ template<typename QuaternionType>
void check_stddeque_quaternion(const QuaternionType&) void check_stddeque_quaternion(const QuaternionType&)
{ {
typedef typename QuaternionType::Coefficients Coefficients; typedef typename QuaternionType::Coefficients Coefficients;
QuaternionType x(Coefficients::Random()), y(Coefficients::Random()); QuaternionType x(Coefficients::Random()), y(Coefficients::Random()), qi=QuaternionType::Identity();
std::deque<QuaternionType> v(10), w(20, y); std::deque<QuaternionType> v(10,qi), w(20, y);
v[5] = x; v[5] = x;
w[6] = v[5]; w[6] = v[5];
VERIFY_IS_APPROX(w[6], v[5]); VERIFY_IS_APPROX(w[6], v[5]);
@ -109,7 +109,7 @@ void check_stddeque_quaternion(const QuaternionType&)
VERIFY_IS_APPROX(w[i], v[i]); VERIFY_IS_APPROX(w[i], v[i]);
} }
v.resize(21); v.resize(21,qi);
v[20] = x; v[20] = x;
VERIFY_IS_APPROX(v[20], x); VERIFY_IS_APPROX(v[20], x);
v.resize(22,y); v.resize(22,y);

View File

@ -18,7 +18,7 @@ void check_stdlist_matrix(const MatrixType& m)
Index rows = m.rows(); Index rows = m.rows();
Index cols = m.cols(); Index cols = m.cols();
MatrixType x = MatrixType::Random(rows,cols), y = MatrixType::Random(rows,cols); MatrixType x = MatrixType::Random(rows,cols), y = MatrixType::Random(rows,cols);
std::list<MatrixType,Eigen::aligned_allocator<MatrixType> > v(10, MatrixType(rows,cols)), w(20, y); std::list<MatrixType,Eigen::aligned_allocator<MatrixType> > v(10, MatrixType::Zero(rows,cols)), w(20, y);
v.front() = x; v.front() = x;
w.front() = w.back(); w.front() = w.back();
VERIFY_IS_APPROX(w.front(), w.back()); VERIFY_IS_APPROX(w.front(), w.back());
@ -33,7 +33,7 @@ void check_stdlist_matrix(const MatrixType& m)
++wi; ++wi;
} }
v.resize(21); v.resize(21, MatrixType::Zero(rows,cols));
v.back() = x; v.back() = x;
VERIFY_IS_APPROX(v.back(), x); VERIFY_IS_APPROX(v.back(), x);
v.resize(22,y); v.resize(22,y);
@ -46,8 +46,8 @@ template<typename TransformType>
void check_stdlist_transform(const TransformType&) void check_stdlist_transform(const TransformType&)
{ {
typedef typename TransformType::MatrixType MatrixType; typedef typename TransformType::MatrixType MatrixType;
TransformType x(MatrixType::Random()), y(MatrixType::Random()); TransformType x(MatrixType::Random()), y(MatrixType::Random()), ti=TransformType::Identity();
std::list<TransformType,Eigen::aligned_allocator<TransformType> > v(10), w(20, y); std::list<TransformType,Eigen::aligned_allocator<TransformType> > v(10,ti), w(20, y);
v.front() = x; v.front() = x;
w.front() = w.back(); w.front() = w.back();
VERIFY_IS_APPROX(w.front(), w.back()); VERIFY_IS_APPROX(w.front(), w.back());
@ -62,7 +62,7 @@ void check_stdlist_transform(const TransformType&)
++wi; ++wi;
} }
v.resize(21); v.resize(21, ti);
v.back() = x; v.back() = x;
VERIFY_IS_APPROX(v.back(), x); VERIFY_IS_APPROX(v.back(), x);
v.resize(22,y); v.resize(22,y);
@ -75,8 +75,8 @@ template<typename QuaternionType>
void check_stdlist_quaternion(const QuaternionType&) void check_stdlist_quaternion(const QuaternionType&)
{ {
typedef typename QuaternionType::Coefficients Coefficients; typedef typename QuaternionType::Coefficients Coefficients;
QuaternionType x(Coefficients::Random()), y(Coefficients::Random()); QuaternionType x(Coefficients::Random()), y(Coefficients::Random()), qi=QuaternionType::Identity();
std::list<QuaternionType,Eigen::aligned_allocator<QuaternionType> > v(10), w(20, y); std::list<QuaternionType,Eigen::aligned_allocator<QuaternionType> > v(10,qi), w(20, y);
v.front() = x; v.front() = x;
w.front() = w.back(); w.front() = w.back();
VERIFY_IS_APPROX(w.front(), w.back()); VERIFY_IS_APPROX(w.front(), w.back());
@ -91,7 +91,7 @@ void check_stdlist_quaternion(const QuaternionType&)
++wi; ++wi;
} }
v.resize(21); v.resize(21,qi);
v.back() = x; v.back() = x;
VERIFY_IS_APPROX(v.back(), x); VERIFY_IS_APPROX(v.back(), x);
v.resize(22,y); v.resize(22,y);

View File

@ -47,7 +47,7 @@ void check_stdlist_matrix(const MatrixType& m)
Index rows = m.rows(); Index rows = m.rows();
Index cols = m.cols(); Index cols = m.cols();
MatrixType x = MatrixType::Random(rows,cols), y = MatrixType::Random(rows,cols); MatrixType x = MatrixType::Random(rows,cols), y = MatrixType::Random(rows,cols);
std::list<MatrixType> v(10, MatrixType(rows,cols)), w(20, y); std::list<MatrixType> v(10, MatrixType::Zero(rows,cols)), w(20, y);
typename std::list<MatrixType>::iterator itv = get(v, 5); typename std::list<MatrixType>::iterator itv = get(v, 5);
typename std::list<MatrixType>::iterator itw = get(w, 6); typename std::list<MatrixType>::iterator itw = get(w, 6);
*itv = x; *itv = x;
@ -86,8 +86,8 @@ template<typename TransformType>
void check_stdlist_transform(const TransformType&) void check_stdlist_transform(const TransformType&)
{ {
typedef typename TransformType::MatrixType MatrixType; typedef typename TransformType::MatrixType MatrixType;
TransformType x(MatrixType::Random()), y(MatrixType::Random()); TransformType x(MatrixType::Random()), y(MatrixType::Random()), ti=TransformType::Identity();
std::list<TransformType> v(10), w(20, y); std::list<TransformType> v(10,ti), w(20, y);
typename std::list<TransformType>::iterator itv = get(v, 5); typename std::list<TransformType>::iterator itv = get(v, 5);
typename std::list<TransformType>::iterator itw = get(w, 6); typename std::list<TransformType>::iterator itw = get(w, 6);
*itv = x; *itv = x;
@ -103,7 +103,7 @@ void check_stdlist_transform(const TransformType&)
++itw; ++itw;
} }
v.resize(21); v.resize(21, ti);
set(v, 20, x); set(v, 20, x);
VERIFY_IS_APPROX(*get(v, 20), x); VERIFY_IS_APPROX(*get(v, 20), x);
v.resize(22,y); v.resize(22,y);
@ -126,8 +126,8 @@ template<typename QuaternionType>
void check_stdlist_quaternion(const QuaternionType&) void check_stdlist_quaternion(const QuaternionType&)
{ {
typedef typename QuaternionType::Coefficients Coefficients; typedef typename QuaternionType::Coefficients Coefficients;
QuaternionType x(Coefficients::Random()), y(Coefficients::Random()); QuaternionType x(Coefficients::Random()), y(Coefficients::Random()), qi=QuaternionType::Identity();
std::list<QuaternionType> v(10), w(20, y); std::list<QuaternionType> v(10,qi), w(20, y);
typename std::list<QuaternionType>::iterator itv = get(v, 5); typename std::list<QuaternionType>::iterator itv = get(v, 5);
typename std::list<QuaternionType>::iterator itw = get(w, 6); typename std::list<QuaternionType>::iterator itw = get(w, 6);
*itv = x; *itv = x;
@ -143,7 +143,7 @@ void check_stdlist_quaternion(const QuaternionType&)
++itw; ++itw;
} }
v.resize(21); v.resize(21,qi);
set(v, 20, x); set(v, 20, x);
VERIFY_IS_APPROX(*get(v, 20), x); VERIFY_IS_APPROX(*get(v, 20), x);
v.resize(22,y); v.resize(22,y);

View File

@ -17,7 +17,7 @@ void check_stdvector_matrix(const MatrixType& m)
Index rows = m.rows(); Index rows = m.rows();
Index cols = m.cols(); Index cols = m.cols();
MatrixType x = MatrixType::Random(rows,cols), y = MatrixType::Random(rows,cols); MatrixType x = MatrixType::Random(rows,cols), y = MatrixType::Random(rows,cols);
std::vector<MatrixType,Eigen::aligned_allocator<MatrixType> > v(10, MatrixType(rows,cols)), w(20, y); std::vector<MatrixType,Eigen::aligned_allocator<MatrixType> > v(10, MatrixType::Zero(rows,cols)), w(20, y);
v[5] = x; v[5] = x;
w[6] = v[5]; w[6] = v[5];
VERIFY_IS_APPROX(w[6], v[5]); VERIFY_IS_APPROX(w[6], v[5]);
@ -86,8 +86,8 @@ template<typename QuaternionType>
void check_stdvector_quaternion(const QuaternionType&) void check_stdvector_quaternion(const QuaternionType&)
{ {
typedef typename QuaternionType::Coefficients Coefficients; typedef typename QuaternionType::Coefficients Coefficients;
QuaternionType x(Coefficients::Random()), y(Coefficients::Random()); QuaternionType x(Coefficients::Random()), y(Coefficients::Random()), qi=QuaternionType::Identity();
std::vector<QuaternionType,Eigen::aligned_allocator<QuaternionType> > v(10), w(20, y); std::vector<QuaternionType,Eigen::aligned_allocator<QuaternionType> > v(10,qi), w(20, y);
v[5] = x; v[5] = x;
w[6] = v[5]; w[6] = v[5];
VERIFY_IS_APPROX(w[6], v[5]); VERIFY_IS_APPROX(w[6], v[5]);

View File

@ -31,7 +31,7 @@ void check_stdvector_matrix(const MatrixType& m)
Index rows = m.rows(); Index rows = m.rows();
Index cols = m.cols(); Index cols = m.cols();
MatrixType x = MatrixType::Random(rows,cols), y = MatrixType::Random(rows,cols); MatrixType x = MatrixType::Random(rows,cols), y = MatrixType::Random(rows,cols);
std::vector<MatrixType> v(10, MatrixType(rows,cols)), w(20, y); std::vector<MatrixType> v(10, MatrixType::Zero(rows,cols)), w(20, y);
v[5] = x; v[5] = x;
w[6] = v[5]; w[6] = v[5];
VERIFY_IS_APPROX(w[6], v[5]); VERIFY_IS_APPROX(w[6], v[5]);
@ -100,8 +100,8 @@ template<typename QuaternionType>
void check_stdvector_quaternion(const QuaternionType&) void check_stdvector_quaternion(const QuaternionType&)
{ {
typedef typename QuaternionType::Coefficients Coefficients; typedef typename QuaternionType::Coefficients Coefficients;
QuaternionType x(Coefficients::Random()), y(Coefficients::Random()); QuaternionType x(Coefficients::Random()), y(Coefficients::Random()), qi=QuaternionType::Identity();
std::vector<QuaternionType> v(10), w(20, y); std::vector<QuaternionType> v(10,qi), w(20, y);
v[5] = x; v[5] = x;
w[6] = v[5]; w[6] = v[5];
VERIFY_IS_APPROX(w[6], v[5]); VERIFY_IS_APPROX(w[6], v[5]);