WebAssembly / gc

Branch of the spec repo scoped to discussion of GC integration in WebAssembly
https://webassembly.github.io/gc/
Other
982 stars 70 forks source link

[spec] array.init_elem: bounds check correct? #508

Closed takikawa closed 7 months ago

takikawa commented 7 months ago

The bounds check in the spec for array.init_elem currently has the following text with "larger than or equal to". Should it be "larger than" instead?

image

If d (or s) and n are both zero, then this traps if the array is empty (or the segment is).

I don't think this is the intended behavior since array.new_elem checks "larger than" and the tests also don't trap in this case (e.g., this test case).

rossberg commented 7 months ago

Yes, that looks like a mistake in the prose; the same for array.init_data. The formal rules are correct. Please see #509 for a fix.