3 ms·
Even modern C++ isn't memory safe. Most straightforward example is to move a uniq_ptr, which makes it a nullptr, ready to be dereferenced and cause UB.
by steveklabnik 10y ago
Even modern C++ isn't memory safe. Most straightforward example is to move a uniq_ptr, which makes it a nullptr, ready to be dereferenced and cause UB.
- ar15saveslives 10y agoHow does it happen? Non-const unique_ptr& used as a function parameter?
- steveklabnik 10y agohttp://www.steveklabnik.com/uniq_ptr_problem/ http://www.steveklabnik.com/uniq_ptr_problem/
- ar15saveslives 10y agoI can simplify your example: unique_ptr<int> p; auto n = *p; // C++ kills!