Skip to content
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

Describe integer overflow semantics in the manual. #9801

Closed
nejucomo opened this issue Oct 10, 2013 · 3 comments
Closed

Describe integer overflow semantics in the manual. #9801

nejucomo opened this issue Oct 10, 2013 · 3 comments

Comments

@nejucomo
Copy link

Please add a section on integer overflow (and underflow) semantics for signed/unsigned integers.

The only mention of "overflow" I see in the manual is 6.1.3.2.4 Behaviour not considered unsafe which doesn't define overflow semantics.

It would also help to augment 7.2.11.5 Type cast expressions to declare that the overflow semantics apply there with a cross-link. There may be other cases where it's not obvious that overflow semantics apply so those sections should cross-link also.

@Aatch
Copy link
Contributor

Aatch commented Oct 10, 2013

The widening behaviour should also be documented in the Type Cast section, since it currently isn't. While the widening behaviour for unsigned integral values is fairly obvious, it would be worth noting the behaviour for signed integral values.

// A cast from a signed value widens with signed-extension
(-1i8 as i16, -1i8 as u16) // (-1i16, 65535u16)
// A cast from an unsigned value widens with zero-extension
(1u8 as i16, 1u8 s u16) // (1, 1)

@aturon aturon added the A-docs label Jun 3, 2014
@emberian
Copy link
Member

Ever more relevant with overflow now being defined as a panic!

@steveklabnik
Copy link
Member

https://github.com/rust-lang/rfcs/blob/master/text/0560-integer-overflow.md was accepted, and while this ticket is still valid, I have a 'go through all RFCs' bug over at #20137, so I'm closing this one, since that one is more comprehensive.

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

5 participants