Skip to content

f32::rem fails on wasm32-unknown-emscripten #42629

Closed
@malbarbo

Description

@malbarbo

This example (test for issue #27859):

#[inline(never)]
fn foo(a: f32, b: f32) -> f32 {
    a % b
}

#[inline(never)]
fn bar(a: f32, b: f32) -> f32 {
    ((a as f64) % (b as f64)) as f32
}

fn main() {
    let unknown_float = std::env::args().len();
    println!("{}", foo(4.0, unknown_float as f32));
    println!("{}", foo(5.0, (unknown_float as f32) + 1.0));
    println!("{}", bar(6.0, (unknown_float as f32) + 2.0));
    println!("{}", bar(7.0, (unknown_float as f32) + 3.0));
}

fails to compile for wasm32-unknown-emscripten with the error:

[wasm-validator error in function $__ZN1x3foo17h4d65114cf314b7c3E] 3 != 4: call param types must match, on
[f64] (call $f64-rem
 [f32] (get_local $4)
 [f32] (get_local $5)
)

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-testsuiteArea: The testsuite used to check the correctness of rustcC-bugCategory: This is a bug.O-wasmTarget: WASM (WebAssembly), http://webassembly.org/

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions