Store enums wider than int at full width instead of truncating - #354
Open
gennaroprota wants to merge 1 commit into
Open
Store enums wider than int at full width instead of truncating#354gennaroprota wants to merge 1 commit into
gennaroprota wants to merge 1 commit into
Conversation
gennaroprota
force-pushed
the
fix/enum-serialization-preserves-wide-values
branch
2 times, most recently
from
July 23, 2026 06:06
58e3c6e to
ac1489c
Compare
gennaroprota
force-pushed
the
fix/enum-serialization-preserves-wide-values
branch
2 times, most recently
from
July 29, 2026 09:37
8c43a7b to
0055757
Compare
Enumerator serialization cast every value to `int` on save and back on load. For an `enum` whose underlying type does not fit in an `int`, that cast silently truncated the value, and users could not intervene because the archive routes every enum through this path before any user serialization is consulted. An enum is now saved through an integer sized to its underlying type: `int` when the underlying type is no wider than `int`, otherwise the underlying type itself. The common case (including scoped enums that do not name a type, and narrow underlying types such as `char`, which stay on the `int` path to avoid the archives' character handling) is byte for byte identical to before, so existing archives and data are unaffected. Only enums that genuinely need the extra width change on the wire, and those were being corrupted anyway. The archive library version is bumped to 21. Fixes #353.
gennaroprota
force-pushed
the
fix/enum-serialization-preserves-wide-values
branch
from
July 29, 2026 09:39
0055757 to
1501101
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Enumerator serialization cast every value to
inton save and back on load. For anenumwhose underlying type does not fit in anint, that cast silently truncated the value, and users could not intervene because the archive routes every enum through this path before any user serialization is consulted.An enum is now saved through an integer sized to its underlying type:
intwhen the underlying type is no wider thanint, otherwise the underlying type itself. The common case (including scoped enums that do not name a type, and narrow underlying types such as char, which stay on the int path to avoid the archives' character handling) is byte for byte identical to before, so existing archives and data are unaffected. Only enums that genuinely need the extra width change on the wire, and those were being corrupted anyway.The archive library version is bumped to 21.
Fixes issue #353.