Skip to content

Fix reading of RNTuple std::bitset with 32 to 48 bits - #430

Merged
linev merged 1 commit into
root-project:devfrom
sebxt:fix/rntuple-bitset-over-31-bits
Oct 21, 2026
Merged

linev merged 1 commit into
root-project:devfrom
sebxt:fix/rntuple-bitset-over-31-bits

Conversation

@sebxt

@sebxt sebxt commented Oct 20, 2026

Copy link
Copy Markdown
Contributor

This Pull request:

BitsetReaderItem combined bits with res |= 1 << len. JavaScript shifts are 32 bit signed, so for std::bitset<N> with 32 <= N <= 48 (still returned as number) bit 31 produced a negative value and higher bits wrapped around.

Changes:

  1. modules/rntuple.mjs: use res += 2 ** len for the number case
  2. demo/node/rntuple_bitset_test.cxx and rntuple_bitset_test.root: small RNTuple with std::bitset<32> and std::bitset<48> fields, written with ROOT 6.38
  3. demo/node/rntuple_bitset_test.js: reads all entries and compares with expected values, exits with error on mismatch
  4. .github/workflows/jsroot-ci.yml: run the new test in all three jobs

Fixes:

Wrong values when reading std::bitset fields with more than 31 bits and at most 48 bits.

Fixes #429

Signed-off-by: Sebastian Turner <sebastiant3484@gmail.com>
@linev
linev requested a review from silverweed October 21, 2026 05:23
@linev linev self-assigned this Oct 21, 2026
@linev
linev merged commit febc496 into root-project:dev Oct 21, 2026
18 checks passed
@linev

linev commented Oct 21, 2026

Copy link
Copy Markdown
Member

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants