Skip to content

Commit 9340ed2

Browse files
authored
wasm-encoder: fix encoding of f32 and f64 constant values in TryFrom<wasmparser::ConstExpr> (#1591)
1 parent acb410e commit 9340ed2

File tree

1 file changed

+2
-2
lines changed
  • crates/wasm-encoder/src/core

1 file changed

+2
-2
lines changed

crates/wasm-encoder/src/core/code.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3531,10 +3531,10 @@ impl<'a> TryFrom<wasmparser::ConstExpr<'a>> for ConstExpr {
35313531
Some(Ok(wasmparser::Operator::I32Const { value })) => ConstExpr::i32_const(value),
35323532
Some(Ok(wasmparser::Operator::I64Const { value })) => ConstExpr::i64_const(value),
35333533
Some(Ok(wasmparser::Operator::F32Const { value })) => {
3534-
ConstExpr::f32_const(value.bits() as _)
3534+
ConstExpr::f32_const(f32::from_bits(value.bits()))
35353535
}
35363536
Some(Ok(wasmparser::Operator::F64Const { value })) => {
3537-
ConstExpr::f64_const(value.bits() as _)
3537+
ConstExpr::f64_const(f64::from_bits(value.bits()))
35383538
}
35393539
Some(Ok(wasmparser::Operator::V128Const { value })) => {
35403540
ConstExpr::v128_const(i128::from_le_bytes(*value.bytes()))

0 commit comments

Comments
 (0)