Closed
Description
While trying to pass std::numeric_limits<uint64_t>::max()
through to JS in bigint mode, I hit an issue where I get a -1 on the JS side. I would expect the value to come through correctly as bigint can represent a number that large.
I can reproduce this with a cpp file with a JS library as follows:
Put this in main.cpp
#include <iostream>
#include <emscripten/bind.h>
#include <emscripten/emscripten.h>
extern "C" {
extern void my_js(uint64_t value);
}
int main() {
std::cout << std::numeric_limits<uint64_t>::max() << std::endl;
my_js(std::numeric_limits<uint64_t>::max());
return 0;
}
Put this in main.js
:
mergeInto(LibraryManager.library, {
my_js: function(value) {
console.log('value', value);
},
});
Then compile with this command:
emcc --js-library main.js -s WASM_BIGINT main.cpp -o test.html
This gives me the following output when I load test.html:
18446744073709551615
test.js:4286 value -1n
Metadata
Metadata
Assignees
Labels
No labels