小编And*_*ela的帖子

使用Clang 3.9时,为什么返回复制的Matrix3d元素导致输出错误?

使用-O2on Clang 3.9 编译以下示例会导致reproFunction 1.9038e+185在调用时返回garbage()main:

double reproFunction(const Eigen::Matrix3d& R_in)
{
  const Eigen::Matrix3d R = R_in;

  Eigen::Matrix3d Q = R.cwiseAbs();

  if(R(1,2) < 2) {
    Eigen::Vector3d n{0, 1, R(1, 2)};
    double s2 = R(1,2);
    s2 /= n.norm();
  }
  return R(1, 2);
}

int main() {
  Eigen::Matrix3d R;
  R = Eigen::Matrix3d::Zero(3,3); 

  // This fails - reproFunction(R) returns 0
  R(1, 2) = 0.7;
  double R12 = reproFunction(R);
  bool are_they_equal = (R12 == R(1,2));
  std::cout << "R12 == R(1,2): …
Run Code Online (Sandbox Code Playgroud)

clang eigen eigen3

5
推荐指数
1
解决办法
107
查看次数

标签 统计

clang ×1

eigen ×1

eigen3 ×1