News for hackers. Stuff that matters.
Re:Learn Rust with entirely too many linked lists (2019) by aw1621107 on Saturday February 22, 2020 @01:14PM (#22392388)
> AIUI, there are some hardware architectures where even creating a wild pointer might be undefined behavior, regardless of whether that pointer is subsequently dereferenced

Would you be able to point me to some references for such hardware? Im not sure how that would work (at least based on my admittedly limited amount of experience). Wouldn’t a pointer look like any other integer right up until it’s used as a memory operand? Or would said architecture have some way to distinguish pointers and a “regular” integer in registers?

Re:Learn Rust with entirely too many linked lists (2019) by Hello71 on Saturday February 22, 2020 @01:30PM (#22392478)
Allegedly, some platforms have pointer trap representations, where a certain pointer can be created, but may not be used in any operations of that type. No modern systems have such trap representations for pointer types, but the C standard inherits their legacy, and, more importantly, C compilers use it as justification for certain types of optimizations. Since it's not a hardware limitation, Rust can perfectly well take the opposite path and say that the compiler may not use it for those optimizations.

https://stackoverflow.com/questions/6725809/trap-representat...

Re:Learn Rust with entirely too many linked lists (2019) by zozbot234 on Saturday February 22, 2020 @02:18PM (#22392745)
> No modern systems have such trap representations for pointer types

This may be incidentally true, but "address sanitizer"-like features are becoming more common on modern hardware, and while these do not currently trap on creation/manipulation of a 'wild' pointer (since, strictly speaking, a trap only happens on dereferencing), there's no solid reason to expect this to remain the case in the future.

Re:Learn Rust with entirely too many linked lists (2019) by int_19h on Saturday February 22, 2020 @04:02PM (#22393304)
I don't see how you could trap creation or manipulation, since those pointers are stored in registers and/or memory, and both are fundamentally untyped. How would the hardware even know that something is a pointer, on any architecture that is popular today?
Re:Learn Rust with entirely too many linked lists (2019) by saagarjha on Saturday February 22, 2020 @08:13PM (#22394461)
Because you use typed instructions to access them. For example, on ARM with pointer authentication you’ll sign pointers and unsign them right before using them. If you forge a pointer it’ll cause a crash when it’s used because its signature will be incorrect.
Re:Learn Rust with entirely too many linked lists (2019) by int_19h on Saturday February 22, 2020 @09:11PM (#22394643)
But that would still happen at the point of dereference, no? Or does it allow to tag even operations like moves and adds?
Re:Learn Rust with entirely too many linked lists (2019) by nicoburns on Sunday February 23, 2020 @07:19AM (#22396504)
> C compilers use it as justification for certain types of optimizations

I believe that the Rust compiler is free to make it's own choices about what is considered valid, and which optimisations it wants to enable. It doesn't need to follow C's lead here.

Re:Learn Rust with entirely too many linked lists (2019) by Hello71 on Tuesday February 25, 2020 @01:31PM (#22415772)
isn't that what I said