Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

https://news.ycombinator.com/item?id=27941675

>No. Unsafe Rust only gets to do three things that aren't related to the "unsafe" keyword itself.

>[...]

>Your C program is free to define x as an array with four elements and then access x[6] anyway - but Rust deliberately cannot do that. Not in Safe Rust, but also not in Unsafe Rust either.

>[...]

>In fact by default the Rust compiler would warn you, if you write unsafe { foo[z] = 0; } that unsafe isn't doing anything useful here and you should remove it. That array dereference either is or, if z is small enough, is not, an overflow, and either way unsafe makes no difference.



Consider applying for YC's Winter 2026 batch! Applications are open till Nov 10

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: