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

This post is subtly wrong: "multiple read-only pointers XOR one mutable pointer" is actually "multiple read-only references XOR one mutable reference".

It _is_ valid to have multiple mutable pointers, just as C and C++ allow. It's when you have multiple live, mutable references (including pointers created from live mutable references) that you end up in UB territory.



Smaller follow up, it's multiple read-only references NAND one mutable reference, since it's also safe to have no references.


They might mean in the sense of data races, which can happen in other languages with pointers. In unsafe code, Rust exchanges that (kinda) for upholding Rust's reference rules, which is its own flavor of UB. Although if you have long-lived raw pointers, the data races come back too. Free UB!




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

Search: