diff --git a/gtsam/navigation/MagFactor.h b/gtsam/navigation/MagFactor.h index 79677c0c6..c2ccb31ff 100644 --- a/gtsam/navigation/MagFactor.h +++ b/gtsam/navigation/MagFactor.h @@ -54,8 +54,11 @@ public: static Point3 unrotate(const Rot2& R, const Point3& p, boost::optional HR = boost::none) { Point3 q = Rot3::yaw(R.theta()).unrotate(p, HR); - if (HR) - *HR = HR->col(2); + if (HR) { + // assign to temporary first to avoid error in Win-Debug mode + Matrix H = HR->col(2); + *HR = H; + } return q; }