1(module $m 2 (table (export "table") funcref (elem $zero $zero $zero $zero $zero $zero $zero $zero $zero $zero)) 3 4 (func $zero (result i32) 5 (i32.const 0)) 6 7 (func (export "indirect-call") (param i32) (result i32) 8 local.get 0 9 call_indirect (result i32))) 10 11(register "m" $m) 12 13(assert_trap 14 (module 15 (table (import "m" "table") 10 funcref) 16 17 (func $one (result i32) 18 (i32.const 1)) 19 20 ;; An in-bounds segment that should get initialized in the table. 21 (elem (i32.const 7) $one) 22 23 ;; Part of this segment is out of bounds, so none of its elements should be 24 ;; initialized into the table, and it should trap. 25 (elem (i32.const 9) $one $one $one) 26 ) 27 "out of bounds" 28) 29 30;; The first `$one` segment *was* initialized OK. 31(assert_return (invoke "indirect-call" (i32.const 7)) (i32.const 1)) 32 33;; The second `$one` segment is partially out of bounds, and therefore none of 34;; its elements were written into the table. 35(assert_return (invoke "indirect-call" (i32.const 9)) (i32.const 0)) 36