Open
Description
I tried this code:
pub fn foo(buf: &[u8], alloced_size: usize) -> &[u8] {
if alloced_size.checked_add(1).map(|total| buf.len() < total).unwrap_or(true) {
return &[];
}
let size = buf[0];
&buf[1..1 + usize::min(alloced_size, usize::from(size))]
}
The assembly code has two generated panics here when none can happen.
Metadata
Metadata
Assignees
Labels
Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues.Area: MIR optimizationsCategory: 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.Relevant to the compiler team, which will review and decide on the PR/issue.