-
Notifications
You must be signed in to change notification settings - Fork 13.2k
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
Clarify the semantics of type cast #16963
Comments
Now I see that number casts are handled by Basically they are translated into Seems like they are all implemented in the "least surprising" way for C programmers, but still, they should be rigorously defined/documented in the language reference manual because they are fundamental in a serious system programming. |
I can imagine that this depends on the hardware. Apart from that I think the following two rules describe
The first paragraph comes from the C standard, the second one is implementation defined in C. |
This is effectively part of #16676, so i'm giving it a close, as we'll address that as part of that. |
fix: ADT hover considering only type or const len not lifetimes I feel like test doesn't do much. Please suggest if I should improve it? Fixes rust-lang#16963
The current spec is not clear about such expressions as
-1i32 as uint as i32 == -1i32
hold or not.http://doc.rust-lang.org/rust.html#type-cast-expressions
Cf: Java8 spec http://docs.oracle.com/javase/specs/jls/se8/html/jls-5.html#jls-5.5
Background: I began to worry about this when I noticed some codes in
libnative
castos::errno()
intouint
though POSIX defineserrno
to be a Cint
variable (on Linux, none ofE***
actually have a negative value.)http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/errno.h.html
The text was updated successfully, but these errors were encountered: