wasm-c-api icon indicating copy to clipboard operation
wasm-c-api copied to clipboard

null references to functions

Open sjamesr opened this issue 1 year ago • 1 comments

Hi all,

Is there a way to create a dangling funcref using the C API? We can create non-null references by using wasm_func_as_ref, but I don't see any way to create a null funcref.

I'm trying to implement a spec test runner that can run the following test:

(assert_return (invoke "select-funcref" (ref.null func) (ref.null func) (i32.const 1)) (ref.null func))

I need to be able to take those (ref.null func) literals and turn them into wasm_val_t representing a null pointer to function. Is there any way to do this in the current API? If not, can we add a function such as wasm_func_null_ref that returns one?

(see the original test)

sjamesr avatar Nov 26 '24 18:11 sjamesr

You should be able to simply use a C/C++ NULL as the C-side representation of a null reference.

rossberg avatar Nov 26 '24 19:11 rossberg