UB in Rust vs C
UB in Rust vs C
Posted Aug 16, 2024 10:08 UTC (Fri) by intelfx (subscriber, #130118)In reply to: UB in Rust vs C by mb
Parent article: Standards for use of unsafe Rust in the kernel
> If you construct a reference from a Null-pointer, it is insta-UB. You don't even have to dereference it.
>
> The only way a compiler could "support" this <…>
>
> The only way a compiler could "support" this <…>
I will admit I really don’t follow this concept. Why, exactly, is constructing a reference from a null pointer an “insta-UB”?
There is a lot of talk that “Rust does not create UBs from thin air” and that every UB in Rust is “sane” and actually needed to achieve some desirable thing; but what exactly is being achieved by this (as compared to only declaring *dereferencing* an invalid reference an UB)?
