Rust Memory Safety

The cluster debates Rust's memory safety guarantees, focusing on the role of 'unsafe' code, its necessity for nontrivial programs, and comparisons to C/C++ where unsafe Rust is argued to be safer despite not being fully memory-safe.

➡️ Stable 0.8x Programming Languages
9,737
Comments
15
Years Active
5
Top Authors
#4645
Topic ID

Activity Over Time

2012
12
2013
33
2014
245
2015
316
2016
620
2017
678
2018
408
2019
553
2020
796
2021
888
2022
1,280
2023
1,011
2024
1,134
2025
1,650
2026
115

Keywords

e.g JS youtube.com PolySync UB HN docs.rs adacore.com AUTOSTAR Rules.md rust unsafe memory safe memory safety safety code bugs keyword guarantees

Sample Comments

dbaupp Nov 5, 2016 View on HN

What's a specific memory safety issue Rust has outside `unsafe` code?

jjnoakes Aug 22, 2022 View on HN

Unsafe rust has numerous safety checks above and beyond C++...

hermanradtke Oct 30, 2024 View on HN

Unsafe Rust is much safer than C

e93849 Sep 26, 2023 View on HN

Unsafe rust is not a memory-safe language.

torginus Dec 17, 2025 View on HN

Sorry, but this is like saying 'when I am not wrong, I am right 100% of the time'.The devs didn't write unsafe Rust to experience the thrills of living dangerously, they wrote it because the primitives were impossible to express in safe Rust.If I were to write a program in C++ that has a thread-safe doubly linked list in it, I'd be able to bet on that linked list will have safety bugs, not because C++ is an unsafe language, but because multi-threading is hard. In fact,

Too Apr 8, 2018 View on HN

It has everything to do with unsafe. Because outside unsafe you are forced to use the borrow checker, among other things, preventing you from thrashing memory with 100% guarantee. The number of ways you can thrash memory in c++ can't even by listed, especially not when it comes to object lifetime, so there is no equivalent subset of c++ providing those 100% guarantees. If you do such a mistake just once, the whole execution of the rest of your program might be randomized. Multiply all those

jjnoakes Feb 5, 2023 View on HN

Rust is absolutely a safe language, and in more ways than just memory safety. The only way to get unsafe code in rust is to opt in to unsafety with a keyword that can easily be checked for, so that you can decide for yourself to enforce that no code in your project uses it.And unless you are writing a few specific types of code, using unsafe usually isn't ever necessary at all.The complexity is also very much not an issue in practice. If you rub up against complexity in C++, you might

rapsey Feb 25, 2020 View on HN

Rust is memory safe. It does not need this treatment.

bitwize Dec 19, 2025 View on HN

Safe Rust eliminates some of the more common memory bugs in C. The bug under discussion was written in unsafe Rust—but even that doesn't obviate the huge advantages Rust has over C. Even unsafe Rust, for instance, has far fewer UB gotchas than C. And with Rust, you can isolate the tricky bits in 'unsafe' blocks and write higher-level logic in safe Rust, giving your code an extra layer of protection. C is 100% unsafe—"unsafe at any speed" as I like to say.

bregma Aug 8, 2021 View on HN

So you're saying Rust is safe because it does exactly what C does?