The following Code runs without throwing a segemntation fault error. However, the call to
std::cout << vec.size() << std::endl
The same code with just int throws a segmentation fault error, as expected.
Your expectation is wrong. Undefined Behavior does not guarantee that your program would crash. It could be a surprise for you but behavior is undefined.