异常:EXC_BAD_INSTRUCTION(代码=EXC_I386_INVOP,子代码=0x0)使用 C++

Exception: EXC_BAD_INSTRUCTION (code=EXC_I386_INVOP, subcode=0x0) using C++

The problem is as the picture shows

vector<int> printMatrix(vector<vector<int> > matrix) {
    if (matrix.empty()) {
        return vector<int>();
    }
    this->matrix = std::move(matrix);
    int startRow = 0, lastRow = this->matrix.size() - 1;
    int startCol = 0, lastCol = this->matrix[0].size() - 1;
    while (startRow <= lastRow && startCol <= lastCol) {
        printCircle(startCol, lastCol, startRow, lastRow);
        ++startCol, --lastCol, ++startRow, --lastRow;
    }
}

当变量 startRow 小于 lastRow 时它工作正常。但是,一般来说,当 startRow 大于 lastRow 时,应该退出 while 循环但会引发 Exception: EXC_BAD_INSTRUCTION (code=EXC_I386_INVOP, subcode=0x0)。如图所示,我对引发的异常感到困惑。

vector<int> printMatrix(vector<vector<int> > matrix) {
    if (matrix.empty()) {
        return vector<int>();
    }
    this->matrix = std::move(matrix);
    int startRow = 0, lastRow = this->matrix.size() - 1;
    int startCol = 0, lastCol = this->matrix[0].size() - 1;
    while (startRow <= lastRow && startCol <= lastCol) {
        printCircle(startCol, lastCol, startRow, lastRow);
        ++startCol, --lastCol, ++startRow, --lastRow;
    }
    // **** return a vector here ****
}

需要return函数中的向量,或将其更改为无效。