Skip to content

Matrix operator== does not check for correct size and returns true for empty matrix comparisons.

Submitted by Simon Lynen

Assigned to Nobody

Link to original bugzilla bug (#1061)
Version: 3.2

Description

Operator == does not check for size and incorrectly returns true for comparison of (partically) dynamic matrix with random matrix.

TEST(A, B) {
typedef Eigen::Matrix<double, 10, Eigen::Dynamic> Type;
Type a;
a.setRandom(10, 5);
Type b;
EXPECT_FALSE(a == b); // Fails.
Type c;
c.setRandom(10, 5);
EXPECT_FALSE(a == c); // Passes.
}

TEST(A, C) {
typedef Eigen::Matrix<double, Eigen::Dynamic, Eigen::Dynamic> Type;
Type a;
a.setRandom(10, 5);
Type b;
EXPECT_FALSE(a == b); // Fails.
Type c;
c.setRandom(10, 5);
EXPECT_FALSE(a == c); // Passes.
}

Edited by Antonio Sánchez