|
|
Log in / Subscribe / Register

UB in Rust vs C

UB in Rust vs C

Posted Aug 19, 2024 0:34 UTC (Mon) by intelfx (subscriber, #130118)
In reply to: UB in Rust vs C by khim
Parent article: Standards for use of unsafe Rust in the kernel

> tive fix for the billion dollars mistake, essentially. References, in Rust, couldn't be null, attempting to create such a reference is an instant UB

Here you're just restating the question and handwaving vigorously. This is not an answer.

>but Option<&T> can hold None and, more importantly, it's guaranteed that in-memory representation for None in Option<&T> is the exact same thing as null in pointer and it's even guaranteed that it would be the same as null in pointer used by C on that platform!

Okay, yeah, so if I correctly understand what you are trying to say here, it's to make niches optimization possible. I didn't think of it.


to post comments


Copyright © 2026, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds