-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Fixed length array type with negative count is accepted #15917
Comments
Possibly another face of #5477? |
Can be easily fixed after #15709 landed |
@hirschenberger I don't think #15709 is related. The issue here isn't an undetected overflow. The issue is it blindly accepts int expressions without testing if the value is non-negative. |
@kballard The size of the Array is parsed here as an https://github.com/rust-lang/rust/blob/master/src/libsyntax/parse/parser.rs#L2038 So the overflow already happened. With #15709 we get the chance, to check for negative literals and also got the full |
@hirschenberger It's parsed as an |
I think this can be closed now. |
Nope, still reproduces. Your test actually tests constructing a value. But the type expression fn main() {
let x: [uint, ..-1];
} |
@kballard sorry, I totally oversaw that this issue is about a type declaration, not a value. |
Rust doesn't actually have |
internal: Sync from downstream
A fixed length array type is allowed to be declared with a negative count. This is interpreted as the uint that would result from coercion, so on a 64-bit machine,
[uint, ..-1]
is considered the same as[uint, ..18446744073709551615]
.This should probably be a compiler error, as negative counts don't make sense. Negative repeat counts in array expressions are already disallowed (as of #6985).
The text was updated successfully, but these errors were encountered: