Y
Hacker News
new
|
ask
|
show
|
jobs
by
steveklabnik
3528 days 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.
1 comments
ar15saveslives
3528 days ago
How does it happen? Non-const unique_ptr& used as a function parameter?
link
steveklabnik
3528 days ago
http://www.steveklabnik.com/uniq_ptr_problem/
link
ar15saveslives
3527 days ago
I can simplify your example:
unique_ptr<int> p; auto n = *p; // C++ kills!
link