I would expect the following code to segmentation fault before it gets inside the method and print anything. Why doesn't it? How come the execution can go inside the method and print output for example?
#include <memory>
#include <vector>
#include <iostream>
class Foo{
public:
void method(int x){
std::cout << "wut" << std::endl;
m_list.push_back(x);
}
private:
std::vector<int> m_list;
};
int main()
{
std::unique_ptr<Foo> example;
example->method(0);
}