Open
Description
I tried this code on rustc nightly (rustc 1.71.0-nightly (c4190f2d3 2023-05-07)
) on godbolt and the assembly code contains some unnecessary checks, but not when changing the value of N
to anything different than 24 (but not out of bounds for a
) or changing the version to 1.69.0 or beta
const N: usize = 24;
pub fn example(a: Vec<u8>) -> u8 {
if a.len() != 32 {
return 0;
}
let a: [u8; 32] = a.try_into().unwrap();
a[15] + a[N]
}
Metadata
Metadata
Assignees
Labels
Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues.Category: This is a bug.Category: An issue highlighting optimization opportunities or PRs implementing suchCall for participation: An issue has been fixed and does not reproduce, but no test has been added.Issue: Problems and improvements with respect to performance of generated code.Status: A Minimal Complete and Verifiable Example has been found for this issueRelevant to the compiler team, which will review and decide on the PR/issue.