Skip to content

Fixed length array type with high un-suffixed count literal incorrectly treated as negative count #15919

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
lilyball opened this issue Jul 23, 2014 · 4 comments · Fixed by #27133
Labels
E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added.

Comments

@lilyball
Copy link
Contributor

A fixed-length array expression with a repeat count with the high bit set and no suffix is incorrectly treated as a negative count.

On a 64-bit machine:

fn main() {
    let x = [0u, ..9223372036854775808];
}

This results in

unnamed.rs:2:20: 2:39 error: expected positive integer for repeat count but found negative integer
unnamed.rs:2     let x = [0u, ..9223372036854775808];
                                ^~~~~~~~~~~~~~~~~~~
error: aborting due to previous error
@hirschenberger
Copy link
Contributor

Can be easily fixed after #15709 landed

@bombless
Copy link
Contributor

fn main() {
    let x = [0usize; 9223372036854775808];
//~^ error: the type `[usize; 9223372036854775808]` is too big for the current architecture
}

Seems that it is not an issue any more.

@pnkfelix pnkfelix added the E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. label Apr 29, 2015
bombless added a commit to bombless/rust that referenced this issue Apr 30, 2015
Manishearth added a commit to Manishearth/rust that referenced this issue May 1, 2015
bombless added a commit to bombless/rust that referenced this issue May 1, 2015
steveklabnik added a commit to steveklabnik/rust that referenced this issue May 12, 2015
steveklabnik added a commit to steveklabnik/rust that referenced this issue May 13, 2015
@bombless
Copy link
Contributor

bombless commented Jun 4, 2015

I'm thinking that if it behave differently on different platforms, is it making it an undefined behavior?
And I think designating an exact behavior for UB cannot possibly be a breaking change?

@lilyball
Copy link
Contributor Author

lilyball commented Jun 5, 2015

@bombless This does not make it undefined behavior. It's very much defined behavior. If it were undefined behavior, then any usize or isize literal would be undefined behavior as well, because the range of valid values is architecture-dependent.

bors added a commit that referenced this issue Jul 19, 2015
bors added a commit to rust-lang-ci/rust that referenced this issue Jan 8, 2024
…eykril

SCIP: populate new SymbolInformation fields

Fixes rust-lang#15919
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants