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

Initializing an array with [0, ..-1] compiles, but causes a segfault at runtime #6977

Closed
bstrie opened this issue Jun 6, 2013 · 4 comments
Closed
Labels
I-crash Issue: The compiler crashes (SIGSEGV, SIGABRT, etc). Use I-ICE instead when the compiler panics.

Comments

@bstrie
Copy link
Contributor

bstrie commented Jun 6, 2013

fn main() {
    let _x = [0, ..-1];
}
@Aatch
Copy link
Contributor

Aatch commented Jun 6, 2013

Seems like a simple oversight, we should make sure that the length is >= 0. I am surprised it doesn't fail trying to emit a -1 alloca though.

@luqmana
Copy link
Member

luqmana commented Jun 6, 2013

Hmm yea, the count part is just casted to a uint so this is doing the equivalent of [0, ..(MAX_UINT)]

@thestinger
Copy link
Contributor

Ah, so this is really just crashing because it hits the bug we have on very large arrays. Perhaps this isn't really a separate issue than the integer literal overflow and large stack array ones?

@Aatch
Copy link
Contributor

Aatch commented Jun 6, 2013

@thestinger either way, negative-length arrays aren't a sane thing to write and should still fail as it's own thing.

bors added a commit that referenced this issue Jun 7, 2013
This fixes #6977. Negative counts don't make sense anyway.
@Aatch Aatch closed this as completed Jun 7, 2013
flip1995 pushed a commit to flip1995/rust that referenced this issue Apr 8, 2021
Add MSRV options to `unnested_or_patterns`

changelog: [`unnested_or_patterns`] can now be configured with the `msrv` config/attribute.

Fixes rust-lang#6953
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
I-crash Issue: The compiler crashes (SIGSEGV, SIGABRT, etc). Use I-ICE instead when the compiler panics.
Projects
None yet
Development

No branches or pull requests

4 participants