Skip to content

non-i32 global initializers silently zeroed — i64.const/f32.const/f64.const inits drop to 0 (init_i32 only decodes i32.const) #649

Description

@avrabe

Found while closing the GI-FPU-001 float-global gap (PR #648). Maintainer-loop finding, not a gale report.

WasmGlobal.init_i32 only decodes a leading i32.const from the init expr (wasm_decoder.rs, #237); everything else records None, and the globals-table materialization uses init_i32.unwrap_or(0) (main.rs) — the slot is silently zeroed.

(module (global $g i64 (i64.const 4886718345))  ;; 0x1_2345_6789
        (func (export "f") (result i64) (global.get $g)))

Verified on v0.33.1 (-t cortex-m4f): compiles rc=0, neither 0x23456789 nor the hi word appears anywhere in the ELF — the read returns 0, wasmtime returns 4886718345.

Fix direction: capture I64Const inits as two words and emit them into the globals table (both words, honoring the #643/#645 slot layout), or — until that lands — flag accesses to non-zero-initialized i64 globals for the #369-style loud-skip so it can't be silent.

Refs #648, #643, #645, #369.

🤖 Generated with Claude Code

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions