-
Notifications
You must be signed in to change notification settings - Fork 59
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Requirements on the target platform C implementation #46
Conversation
|
||
* Some platforms do not have any pointer value that compares equal to `NULL`. | ||
Should we support these platforms? For example, an OS kernel like Linux that | ||
wants to use the `0x0` address. Rust is used for these platforms already. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think Rust should be able to target these platforms but Rust programs can't reference any object at address zero.
* This interacts which the bit-patterns: | ||
|
||
* for which `&T` and `&mut T` have niches, and therefore `Option<&T>` is | ||
`None` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Regardless of the value of NULL
(zero or otherwise), it should be straightforward for the Rust compiler to translate between a pointer and Option<&T>
if the definition of std::ptr::NonNull
were made more flexible; currently its documentation conflates zero and NULL
..
OTOH, I think that would be a breaking change so I think it would be OK to restrict the current edition of Rust to platforms where NULL is zero since there's probably a lot of things in Rust that assume that already.
`None` | ||
* `<*[mut,const] T>::is_null(self)` returns `true` - note that `NonNull` | ||
does not convey any information about the exact representation of its | ||
niche, that is, it is different from `NonZero`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The documentation for NonNull
says "*mut T but non-zero and covariant" (emphasis mine). Later on the documentation says "non-null"; i.e."non-zero" and "non-null" are used interchangeably.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The docs might need fixing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The docs might need fixing.
I agree. However, somebody may have already read the documentation and made the assumption that NULL == 0 based on them, and may then be relying on that, so it should be announced loudly if that change is made. If it isn't too late, it would be good to do it at the same time Rust 2018 edition ships and maybe consider it part of Rust 2018.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is unclear at this point what we are going to require about the niches of &T
, that probably will be part of the discussions about "validity", which are not taking place yet (hence why this is an unresolved question).
So i'm closing this, since everything is in their respective chapters, I think its better to continue doing so for the time being, and like @gankro recommended once we are done with that, try to "independently" gather all those parts in a single document about the C platform. I think that all points made here should go in the section about layout / validity representation of integers and floating points. |
No description provided.