Skip to content

Miscompilation in unoptimized builds on aarch64 with 1.57.0 #92786

Closed
@saethlin

Description

@saethlin

Minimized from a program @jfro was trying to debug.
I tried this code:

fn main() {
    for (i, _) in [0u8].iter().enumerate() {
        let test = i as f32;
        println!("i: {}", test);
        let _wtf = i as u32;
    }
}

I expected to see this happen:

i: 0

Instead, this happened:

i: 536870900

Meta

I see this on aarch64 and not on x86_64. I don't have access to any other architectures. Output is as expected with --release. I can also observe this bug on the previous stable (1.56.1), current beta (1.58.0-beta.3) and current nightly (89b9f7b 2022-01-10).

rustc --version --verbose:

rustc 1.57.0 (f1edd0429 2021-11-29)
binary: rustc
commit-hash: f1edd0429582dd29cccacaf50fd134b05593bd9c
commit-date: 2021-11-29
host: aarch64-unknown-linux-gnu
release: 1.57.0
LLVM version: 13.0.0

Metadata

Metadata

Assignees

Labels

A-LLVMArea: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues.C-bugCategory: This is a bug.P-criticalCritical 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