本征矩阵似乎保留了不同范围内的记忆

Eigen's matrix seems to preserve the memory in the different scope

以下片段,我认为标准输出在 scope1 和 scope2 中必须相同。然而,正如结果显示的那样,没有。结果表明 scope2 中的 m 从 scope1 中继承了一些值。我认为这很奇怪,因为 scope1 中的 m 应该与 scope2 中的 m 无关。有人可以解释为什么会这样吗?

#include<iostream>
#include<Eigen/Core>
using namespace Eigen;

int main(){
  {
    std::cout << "scope1" << std::endl; 
    MatrixXd m(2, 2);
    std::cout << m << std::endl; 
    m << 1, 2, 3, 4;
    std::cout << m << std::endl; 
  }
  {
    std::cout << "scope2" << std::endl; 
    MatrixXd m(2, 2);
    std::cout << m << std::endl; 
    m << 1, 2, 3, 4;
    std::cout << m << std::endl; 
  }
}

输出

scope1
0 0
0 0
1 2
3 4
scope2
0 2
3 4
1 2
3 4

The documentation 说:

Constructs an uninitialized matrix with rows rows and cols columns.

读取uninitialized data has undefined behaviour的程序。