Rust 如何定義空指針?

https://users.rust-lang.org/t/how-does-rust-define-null-pointers/104528#post_1

Rust defines null pointers as “dangling” if they are null or if not all of the bytes they point to are part of the same live allocation. The Rust Reference states that it is incorrect to evaluate a dereference expression on a raw pointer that is dangling or unaligned. In a specific embedded platform where functions are written to address 0x0, the behavior of such code may result in undefined behavior according to Rust’s definition. Guaranteeing the expected functionality in this context would require careful consideration and possibly a different approach.

via The Rust Programming Language Forum – Latest posts

December 28, 2023 at 01:22PM

發佈留言

發佈留言必須填寫的電子郵件地址不會公開。 必填欄位標示為 *