Semantic Bug #1
The program reaches segmentation failure as the max row index of the original matrix is 3 (4 by
5 matrix) , but its instance of matrixData is invoked with a row index of 4, (the value of j),
causing out-of-bounds array access.
Proposed Bug Fix
Line 257 was fixed to swap i and j in the arguments of the function call, to become
copy.setElement(matrixData[i][j], i, j);
Result
The program does not reach segmentation failure when j becomes 4 as 4 is within the column
bounds of the current instance
Able to go into setElements function without segmentation failure
Semantic Bug #2
The program stops updating the copied matrix when j becomes 3 and instead goes into the
error trapping mechanism out of bounds access as the colNum of the copy is 3 but the original
matrix has a colNum of 4
Copy 3 by 3 but origin matrix instance is 4 by 5
Proposed Bug Fix
Line 253 was changed to involve the additional constructor so the row and col size can be set to
the same size as the original matrix (4 by 5): Matrix copy = Matrix(rowsNum, colsNum);
Result
When j is 3, the the code does not detect out of bounds column access and updates the copy
instance
Dimensions of copy matches original matrix instance