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

> Rust screams UB much quicker when it comes to memory semantics than any other language that I know.

If you only use raw pointers, Rust has significantly less UB that C does.

But if you use references, then yeah we have those aliasing rules and they can be quite restrictive.



My brain isn't cached into the issue anymore, because I've since solved the same problem with Zig, but about a year ago there was no way to have a reference counted tagged pointer that points to a boxed DST with the minimum number of bytes. Every path lead through UB or "not yet defined" somewhere.

You wrote a PHD on it so you might have a better idea of the issues that past me ran into, than what present me can still recall ;)


It might still be tricky or even impossible to do that, that sounds very specific. If it is truly impossible we in the UCG would love to hear that. :) We don't want to rule out any legitimate use-case without reasonable alternatives (and yes those are deliberately fuzzy terms), but we do want to guarantee some baseline of optimizations that almost all code can benefit from, and it is okay for us if niche code then becomes harder to write. If we accidentally make it impossible to write though, that would be an issue we'd love to know about.


I have it on my todo list to revisit the Rust implementation at some point. Now that const generics have landed at least some parts of the code should be easier to write.

I'll throw you folks an issue over the fence, should I run into the same problems again, pinky swear ;)

Whats the current state of the art for unsafe code? The guidelines?(https://rust-lang.github.io/unsafe-code-guidelines/)

I found the Rustonomicon, despite it's mythological status, to be quite thin. ^^'


UCG and their Zulip are a good place for thorny "is this UB" questions, yeah. We're thin on documentation indeed. First need to figure out all the rules, then find enough people to write all the educational material to teach them to everyone else. ;)




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

Search: