Closed
Description
In 1.60 the following code causes no allocations:
pub fn main() -> i32 {
let v1 = vec![5, 6, 7];
let v1_iter = v1.iter();
let total: i32 = v1_iter.sum();
println!("{}",total);
total
}
However in nightly there is an allocation, see: https://godbolt.org/z/cq9b1Pnva
EDIT:
Appears there is also a problem with 1.60 and opt-level 2 vs 3: https://godbolt.org/z/8MWjEvPbh
Metadata
Metadata
Assignees
Labels
Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues.Area: Code generationCategory: This is a bug.Medium priorityRelevant to the compiler team, which will review and decide on the PR/issue.Performance or correctness regression from one stable version to another.