Re:Memory safety CVEs differ between Rust and C/C++
by jeffbee on Monday June 15, 2026 @01:44PM
(#48544676)
Hrmm. I don't think there exists a set of compiler flags that will just make an existing C++ (or, worse, a mixed C and C++) project safe to the extent that you suggested. The STL hardening flags don't help for ordinary arrays that aren't accessed via smart pointers, and they don't help code that uses a pointer+offset style of access. As for UAF, nothing in C++ comprehensively prevents you from accessing an invalid stored reference even if you have cranked up the hardening mode to DEBUG. Rust, on the other hand, affirmatively prevents that.
[ Parent
| on HN ]
Re:Memory safety CVEs differ between Rust and C/C++
by jurschreuder on Tuesday June 16, 2026 @06:21PM
(#48563016)
You can also write inline assembly in C++ and then it's not safe.
But no developers working on projects that have been so ultimately battle tested that only memory safety issues remain do that. Professional C++ developers use RAII and containers. If you use raw pointers or raw arrays in C++ you will get 200 code reviewers lecturing you. You will never be able to for long.