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

Compile time bounds checking doesn't work anymore for passed array references #114840

Closed
bluec0re opened this issue Aug 15, 2023 · 1 comment
Closed
Labels
C-bug Category: This is a bug. regression-untriaged Untriaged performance or correctness regression.

Comments

@bluec0re
Copy link

Code

I tried this code:

fn bar(a: &mut [usize; 5]) {
    a[5] = 7;
}

pub fn main() {
    let mut a = [0usize; 5];
    bar(&mut a);
}

I expected to see this happen (as it did with 1.60):

error: this operation will panic at runtime
 --> <source>:2:5
  |
2 |     a[5] = 7;
  |     ^^^^ index out of bounds: the length is 5 but the index is 5
  |
  = note: `#[deny(unconditional_panic)]` on by default

Instead, this happened:

Compiles and than fails at runtime

thread 'main' panicked at 'index out of bounds: the len is 5 but the index is 5', /app/example.rs:2:5
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

Version it worked on

It most recently worked on: 1.60

Version with regression

1.61 onwards

Looks similar to this older bug report: #98444

@bluec0re bluec0re added C-bug Category: This is a bug. regression-untriaged Untriaged performance or correctness regression. labels Aug 15, 2023
@rustbot rustbot added needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. I-prioritize Issue: Indicates that prioritization has been requested for this issue. labels Aug 15, 2023
@apiraino
Copy link
Contributor

Yeah, I think it's a duplicate of #98444 (which IIUC was never completely solved).

I'm closing this as duplicate and reopening the former (in case it's not the correct procedure, feel free to reopen)

@rustbot label -I-prioritize -needs-triage

@rustbot rustbot removed I-prioritize Issue: Indicates that prioritization has been requested for this issue. needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels Aug 15, 2023
@apiraino apiraino closed this as not planned Won't fix, can't repro, duplicate, stale Aug 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug. regression-untriaged Untriaged performance or correctness regression.
Projects
None yet
Development

No branches or pull requests

3 participants