Skip to content

wrong result for i128 division on 32-bit targets #41228

Closed

Description

STR

#![feature(i128_type)]

fn main() {
    let x: i128 = -87559967289969187895646876466835277875;
    let y: i128 = 84285771033834995895337664386045050880;
    let z = x / y;

    println!("{}", x);
    println!("{}", y);
    println!("{}", z);
}
$ cargo run
-87559967289969187895646876466835277875
84285771033834995895337664386045050880
-1

$ cross run --target i686-unknown-linux-gnu
-87559967289969187895646876466835277875
84285771033834995895337664386045050880
-12387103594680423864962518064495067137

This is also wrong at least on i686-pc-windows-msvc. Haven't checked whether the related intrinsic is written in Rust or in C atm. But the implementation in rust-lang-nursery/compiler-builtins gives the right result.

Meta

$ rustc -V
rustc 1.18.0-nightly (3b5754e5c 2017-04-10)

cc @est31

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    P-highHigh priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions