New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
wasm2c tests fail on 32-bit due to assumption that pointers are 64-bit #2099
Comments
Also btw if this is helpful: fac.c isn't example code itself; it's the C version of fac.wat after running it through wasm2c. (Rebuilt with |
rathann
added a commit
to rathann/wabt
that referenced
this issue
Jan 8, 2023
The spectest_make_externref() in test/spec-wasm2c-prefix.c:203 assumes that u64 (uint64_t) can be converted to wasm_rt_externref_t (void *). This is not the case on 32-bit platforms. ``` - test/regress/regress-2039.txt expected error code 0, got 1. STDERR MISMATCH: --- expected +++ actual @@ -0,0 +1,19 @@ +out/test/regress/regress-2039/regress-2039-main.c: In function ‘spectest_make_externref’: +out/test/regress/regress-2039/regress-2039-main.c:205:10: error: cast to pointer from integer of different size [-Werror=int-to-pointer-cast] + 205 | return (wasm_rt_externref_t)(x + 1); // externref(0) is not null + | ^ ``` The same error occurs with all wasm2c tests. This fixes WebAssembly#2099.
@keithw I've submitted a PR with just the test failure fix for now. fac.c (or, actually, wasm2c.declarations.c) seems to have more pointer width issues than just the above. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The
spectest_make_externref()
in test/spec-wasm2c-prefix.c:203 assumes thatu64
(uint64_t
) can be converted towasm_rt_externref_t
(void *
). This is not the case on 32-bit platforms:The same error occurs with all wasm2c tests. This can be fixed with a trivial patch:
Additionally, the example code in wasm2c/examples/fac/fac.c makes assumptions that memory addresses are 64-bit, too, for example in lines 71, 81, 97 and 106. The code should use
uintptr_t
instead in the above lines, too.The text was updated successfully, but these errors were encountered: