Skip to content

u128 miscompilation in 1.63.0.2 #137

@ollpu

Description

@ollpu

The following code

#[derive(Debug)]
struct U32Pair {
    a: u32,
    b: u32,
}

#[inline(never)]
fn u128_test(p1: U32Pair) {
    let x = dbg!(p1.a) as u128 * 10;
    dbg!(x);
    let y = x + 1;
    dbg!(y);
}

fn main() {
    u128_test(U32Pair { a: 1, b: 0 });
}

prints (on -C opt-level=z)

[src/main.rs:50] p1.a = 1
[src/main.rs:51] x = 0
[src/main.rs:53] y = 10000000000000000001

The test is reduced from std::thread::sleep which currently gets stuck sleeping forever. It's pretty particular about the details, otherwise it might work correctly or cause panics in the format code.

I've also added this to https://github.com/ollpu/esp-rustc-abi-bug

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions