Skip to content

Fix handling of uint64_t in Embind #24285

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

Merged
merged 10 commits into from
May 9, 2025

Conversation

RReverser
Copy link
Collaborator

Before this fix, uint64_t would be returned as a signed integer from Embind (e.g. if you return UINT64_MAX, it gets returned as -1).

I fixed that behaviour so that unsigned integers are correctly "fixed up" like they already are for uint32_t, and added tests for 64-bit integer limits to test_i64_binding.

In the process I had to also delete the invalid test other.test_embind_long_long - it had incorrect expectations (see commit message for more details) and is now superseded by the correct test mentioned above.

@RReverser RReverser requested review from brendandahl and sbc100 May 8, 2025 14:52
RReverser added 3 commits May 8, 2025 15:53
Test expectations were incorrect: it mixed up int64/uint64 and was returning negative number in uint64 function and expecting the negative sign to be preserved. Now that behaviour of uint64 is fixed, this expectation doesn't hold.

Additionally, it was relying on the `n` suffix being printed by `console.log`, which is not portable and is not printed in e.g. latest Node.js.

The correct test is now better served by test_i64_binding which correctly checks the type limits, signs, and will also run across more engines.
RReverser added 2 commits May 8, 2025 16:47
Not sure why tests pass fine for me locally but not on CI, but it has to be related to RTTI checks...
Copy link
Collaborator

@sbc100 sbc100 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm, but will defer to @brendandahl for final approval

@RReverser
Copy link
Collaborator Author

Will fix test failures a bit later.

@RReverser RReverser requested a review from brendandahl May 8, 2025 21:26
@RReverser RReverser merged commit 6702908 into emscripten-core:main May 9, 2025
28 checks passed
@RReverser RReverser deleted the embind-uint64 branch May 9, 2025 00:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants