Skip to content

Specify pointer-sized integers a bit more #16715

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

Closed
tbu- opened this issue Aug 24, 2014 · 3 comments
Closed

Specify pointer-sized integers a bit more #16715

tbu- opened this issue Aug 24, 2014 · 3 comments

Comments

@tbu-
Copy link
Contributor

tbu- commented Aug 24, 2014

E. g. specify that the largest possible array of u8-sized elements has a length that fits into an int, additionally require that i8 <= int, so that abnormal overflow conditions don't need to be checked, such as in #16701.

@thestinger
Copy link
Contributor

It's already specified enough that those are guarantees. It's not possible to have a larger array because there's a guarantee of it being contiguous and addressable via pointer arithmetic. I don't think the documentation needs to spell out some of the consequences of it being pointer-size.

@tbu-
Copy link
Contributor Author

tbu- commented Sep 16, 2014

The Rust type int is a two's complement signed integer type with target-machine-dependent size. Its size, in bits, is equal to the size of the rust type uint on the same target machine.

– Rust Reference Manual (2014-09-17)

This is the only thing I see that specifies int. I see no guarantee that int is the same as any other integer type, so I don't see where it follows that int is at least 8 bit long. I also see no guarantee why an array can't have the size as size that doesn't fit into an int, for example int::MAX as uint + 1 as that's completely addressable using pointer arithmetic using uint, yet is too big for int.

@steveklabnik
Copy link
Member

I don't think the documentation needs to spell out some of the consequences of it being pointer-size.

Agreed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants