Fix an msan violation in AOS controls code
In a move, the destination can be uninitialized prior to the move (and
the origin should be considered uninitialized after the move).
A swap however assumes that both are initialized before (and thus after
as well).
The ::std::swap was ok with msan in clang 17, but the Eigen-swap was
not.
This is in preparation for updating to clang 17.
Change-Id: I2ef80f5f5a3b34ba8e8d2529ca5ff6c9436ffcd1
Signed-off-by: James Kuszmaul <james.kuszmaul@bluerivertech.com>
diff --git a/frc971/control_loops/hybrid_state_feedback_loop.h b/frc971/control_loops/hybrid_state_feedback_loop.h
index 79e7da7..3732266 100644
--- a/frc971/control_loops/hybrid_state_feedback_loop.h
+++ b/frc971/control_loops/hybrid_state_feedback_loop.h
@@ -86,12 +86,12 @@
StateFeedbackHybridPlant(StateFeedbackHybridPlant &&other)
: index_(other.index_) {
- ::std::swap(coefficients_, other.coefficients_);
- X_.swap(other.X_);
- Y_.swap(other.Y_);
- A_.swap(other.A_);
- B_.swap(other.B_);
- DelayedU_.swap(other.DelayedU_);
+ coefficients_ = ::std::move(other.coefficients_);
+ X_ = ::std::move(other.X_);
+ Y_ = ::std::move(other.Y_);
+ A_ = ::std::move(other.A_);
+ B_ = ::std::move(other.B_);
+ DelayedU_ = ::std::move(other.DelayedU_);
}
virtual ~StateFeedbackHybridPlant() {}
@@ -290,12 +290,11 @@
}
HybridKalman(HybridKalman &&other) : index_(other.index_) {
- ::std::swap(coefficients_, other.coefficients_);
-
- X_hat_.swap(other.X_hat_);
- P_.swap(other.P_);
- Q_.swap(other.Q_);
- R_.swap(other.R_);
+ coefficients_ = ::std::move(other.coefficients_);
+ X_hat_ = ::std::move(other.X_hat_);
+ P_ = ::std::move(other.P_);
+ Q_ = ::std::move(other.Q_);
+ R_ = ::std::move(other.R_);
}
// Getters for Q