Notes
This function is in beta test. Please help improve it in the issues
here.
================================================================= ==31622==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x6070000000f0 at pc 0x55dc7404b0cd bp 0x7ffc7fa14290 sp 0x7ffc7fa14280 READ of size 4 at 0x6070000000f0 thread T0 #0 0x55dc7404b0cc in intMatrix::getElement(int, int) (/out/package/ex3+0x170cc) #1 0x55dc74045f5f in main (/out/package/ex3+0x11f5f) #2 0x7fbadb183b96 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21b96) #3 0x55dc74042ca9 in _start (/out/package/ex3+0xeca9) 0x6070000000f0 is located 16 bytes to the left of 80-byte region [0x607000000100,0x607000000150) allocated by thread T0 here: #0 0x7fbadc8f5448 in operator new(unsigned long) (/usr/lib/x86_64-linux-gnu/libasan.so.4+0xe0448) #1 0x55dc7404a4e2 in __gnu_cxx::new_allocator<int>::allocate(unsigned long, void const*) (/out/package/ex3+0x164e2) #2 0x55dc7404a324 in std::allocator_traits<std::allocator<int> >::allocate(std::allocator<int>&, unsigned long) (/out/package/ex3+0x16324)
Hints
Your answer may be identical to the JOJ answer in the first several lines.
However, the main problem you meet now is Runtime Error. And the exit code of your program is 1, which should be 0.
Please double check your code to solve this problem and try again.
Your Answer
Testing getElement 2: 4 pts Matrix Information: rows: 4 cols: 5 Matrix[1][5] = 1 Matrix[1][1] = 1 Matrix[2][3] = 1
JOJ Answer
Testing getElement 2: 4 pts Matrix Information: rows: 4 cols: 5 Matrix[1][5] = 1 Matrix[1][1] = 1 Matrix[2][3] = 1 Matrix[4][5] = 1