Skip to content

EMULATED_FUNCTION_POINTERS=1 issue with EH and functions returning int64 #7399

@vargaz

Description

@vargaz

Testcase:

#include <cstdio>
#include <cstdint>

int64_t foo (void)
{
	return 5;
}

typedef int64_t (Func) (void);

Func *bar;

int main (void)
{
	bar = foo;

	try {
		printf ("%d\n", bar ());
	} catch (int i) {
	}
}

Compile with:

emsdk_env.sh && emcc -g  -s DISABLE_EXCEPTION_CATCHING=0  -s EMULATED_FUNCTION_POINTERS=1 -s ALIASING_FUNCTION_POINTERS=0 -s EXIT_RUNTIME=1 -s WASM=1 -s BINARYEN=1 foo.cpp

Expected result:

5

Actual result:

exception thrown: TypeError: cannot pass i64 to or from JS
ftCall_j@a.out.js:2221:10
invoke_j@a.out.js:2211:12
legalfunc$invoke_j@a.out.js line 1656 > WebAssembly.instantiate:wasm-function[104]:0xbc16
_main@a.out.js line 1656 > WebAssembly.instantiate:wasm-function[29]:0x5a2
Module._main@a.out.js:2446:10

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions