In the recent CFR 950 div3-D, I came across a **Runtime Error Code: -1073741819** when run with **C++17 (GCC 7-32)**, but AC with **C++20 (GCC 13-64)**. After reading several blogs, it hinted me that I'm making an out of bound mistake using pointers, which in fact I was. I was able to fix my code. And got AC from **C++17** as well.↵
↵
Original Code: [264208915](https://codeforces.net/contest/1980/submission/264208915) (C++17)↵
↵
Fixed Code: [264209191](https://codeforces.net/contest/1980/submission/264209191) (C++17)↵
↵
↵
And I made a few speculations:↵
↵
**C++17 (GCC 7-32)** throws a Runtime Error if we are accessing pointers out of last-bound, but **C++20 (GCC 13-64)** just auto-adjusts it to the last-most element.↵
↵
↵
My proofs:↵
↵
↵
~~~~~↵
vector<int> v = {4,3,2,5};↵
v.erase(v.begin() + 10);↵
~~~~~↵
↵
↵
↵
Gives Runtime Error in **C++17 (GCC 7-32)**: [264205342](https://codeforces.net/contest/1980/submission/264205342)↵
↵
Doesn't give Runtime Error in **C++20 (GCC 13-64)**: [26420524214654](https://codeforces.net/contest/1980/submission/26420524214654)↵
in fact, it just removes the Last Element (5), from the vector (tested locally).↵
↵
My question to the experienced is that are my speculations correct? If yes, then why does **C++20 (GCC 13-64)** has this type of different behavior?
↵
Original Code: [264208915](https://codeforces.net/contest/1980/submission/264208915) (C++17)↵
↵
Fixed Code: [264209191](https://codeforces.net/contest/1980/submission/264209191) (C++17)↵
↵
↵
And I made a few speculations:↵
↵
**C++17 (GCC 7-32)** throws a Runtime Error if we are accessing pointers out of last-bound, but **C++20 (GCC 13-64)** just auto-adjusts it to the last-most element.↵
↵
↵
My proofs:↵
↵
↵
~~~~~↵
vector<int> v = {4,3,2,5};↵
v.erase(v.begin() + 10);↵
~~~~~↵
↵
↵
↵
Gives Runtime Error in **C++17 (GCC 7-32)**: [264205342](https://codeforces.net/contest/1980/submission/264205342)↵
↵
Doesn't give Runtime Error in **C++20 (GCC 13-64)**: [2642
in fact, it just removes the Last Element (5), from the vector (tested locally).↵
↵
My question to the experienced is that are my speculations correct? If yes, then why does **C++20 (GCC 13-64)** has this type of different behavior?