Skip to content

Codegen/allocator regression from 1.60 #97217

Closed
@jgouly

Description

@jgouly

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

No one assigned

    Labels

    A-LLVMArea: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues.A-codegenArea: Code generationC-bugCategory: This is a bug.P-mediumMedium priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.regression-from-stable-to-stablePerformance or correctness regression from one stable version to another.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions