Re:Ask HN: What is the state of C++ vs. Rust?
by ar15saveslives on Thursday October 20, 2016 @01:38PM
(#12754379)
What is "memory safe" for you? If you use C arrays and raw pointers in your C++17 code, it's definitely not memory safe, but the main problem is that it's not modern C++.
[ Parent
| on HN ]
Re:Ask HN: What is the state of C++ vs. Rust?
by steveklabnik on Thursday October 20, 2016 @05:04PM
(#12756154)
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.
Re:Ask HN: What is the state of C++ vs. Rust?
by ar15saveslives on Thursday October 20, 2016 @10:07PM
(#12757697)
How does it happen? Non-const unique_ptr& used as a function parameter?
Re:Ask HN: What is the state of C++ vs. Rust?
by steveklabnik on Friday October 21, 2016 @03:42AM
(#12758824)
Re:Ask HN: What is the state of C++ vs. Rust?
by ar15saveslives on Friday October 21, 2016 @09:13AM
(#12760095)
I can simplify your example:
unique_ptr<int> p;
auto n = *p; // C++ kills!