1*e50d897bSAlex Crichton;;! bulk_memory = true 2*e50d897bSAlex Crichton 39c6884e2SAlex Crichton(module $m 49c6884e2SAlex Crichton (table (export "table") funcref (elem $zero $zero $zero $zero $zero $zero $zero $zero $zero $zero)) 59c6884e2SAlex Crichton 69c6884e2SAlex Crichton (func $zero (result i32) 79c6884e2SAlex Crichton (i32.const 0)) 89c6884e2SAlex Crichton 99c6884e2SAlex Crichton (func (export "indirect-call") (param i32) (result i32) 109c6884e2SAlex Crichton local.get 0 119c6884e2SAlex Crichton call_indirect (result i32))) 129c6884e2SAlex Crichton 139c6884e2SAlex Crichton(register "m" $m) 149c6884e2SAlex Crichton 159c6884e2SAlex Crichton(assert_trap 169c6884e2SAlex Crichton (module 179c6884e2SAlex Crichton (table (import "m" "table") 10 funcref) 189c6884e2SAlex Crichton 199c6884e2SAlex Crichton (func $one (result i32) 209c6884e2SAlex Crichton (i32.const 1)) 219c6884e2SAlex Crichton 229c6884e2SAlex Crichton ;; An in-bounds segment that should get initialized in the table. 239c6884e2SAlex Crichton (elem (i32.const 7) $one) 249c6884e2SAlex Crichton 259c6884e2SAlex Crichton ;; Part of this segment is out of bounds, so none of its elements should be 269c6884e2SAlex Crichton ;; initialized into the table, and it should trap. 279c6884e2SAlex Crichton (elem (i32.const 9) $one $one $one) 289c6884e2SAlex Crichton ) 299c6884e2SAlex Crichton "out of bounds" 309c6884e2SAlex Crichton) 319c6884e2SAlex Crichton 329c6884e2SAlex Crichton;; The first `$one` segment *was* initialized OK. 339c6884e2SAlex Crichton(assert_return (invoke "indirect-call" (i32.const 7)) (i32.const 1)) 349c6884e2SAlex Crichton 359c6884e2SAlex Crichton;; The second `$one` segment is partially out of bounds, and therefore none of 369c6884e2SAlex Crichton;; its elements were written into the table. 379c6884e2SAlex Crichton(assert_return (invoke "indirect-call" (i32.const 9)) (i32.const 0)) 38