Here is my code of what I am doing :
#include <iostream>
#include <vector>
#include <memory>
using namespace std;
int main()
{
  vector<int> ar = {1};
  shared_ptr<int> sp(&ar[0]);
  cout<<*sp<<endl; // ---- [1]
  ar[0] = 10;
  cout<<*sp<<endl; // ---- [2]
  ar.clear();
  cout<<*sp<<endl; // ---- [3]
  return 0;
}
The output is coming to be :
1
10
10
Instead of cout at [3] I think, there should be any error at runtime, since the the object to be accessed is already deleted. How it is printing 10 in [3]? Or should I use any g++ flag, I am just using g++ -std=c++14 a1.cpp && ./a.out
EDIT: On running on Coliru I found out that clang++ is giving
`*** glibc detected *** ./a.out: double free or corruption (fasttop):     0x0000000002138010 ***`
But g++ is not Coliru.
 
     
     
    