Fix 32-bit truncation in the flagset u64 round-trip - #7757
Merged
Conversation
Mission flags are saved to the mission file as the full 64-bit flagset value, but three issues prevented anything larger than 32 bits from being saved as intended: * `stuff_flagset` parsed the value with `stuff_long`, where `atol` clamps anything above `LONG_MAX` * `flagset::from_u64` cast the incoming value to `unsigned long`, truncating bits 32-63 * `flagset::to_u64` used `bitset::to_ulong` where it should use `bitset::to_ullong` Fix these issues and add `static_assert` in the flagset functions to defend against future issues. Also use the proper UINT64_T_ARG where it should be used. This was first triggered by `Limited_support_rearm_pool`, the first mission flag to occupy bit 31. Only mission flags are affected; the other flagset serialization paths were audited and are safe. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This was referenced Aug 31, 2026
wookieejedi
approved these changes
Aug 31, 2026
wookieejedi
pushed a commit
that referenced
this pull request
Sep 2, 2026
Fix 32-bit truncation in the flagset u64 round-trip
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.
Mission flags are saved to the mission file as the full 64-bit flagset value, but three issues prevented anything larger than 32 bits from being saved as intended:
stuff_flagsetparsed the value withstuff_long, whereatolclamps anything aboveLONG_MAXflagset::from_u64cast the incoming value tounsigned long, truncating bits 32-63flagset::to_u64usedbitset::to_ulongwhere it should usebitset::to_ullongFix these issues and add
static_assertin the flagset functions to defend against future issues. Also use the proper UINT64_T_ARG where it should be used.This was first triggered by
Limited_support_rearm_pool, the first mission flag to occupy bit 31. Only mission flags are affected; the other flagset serialization paths were audited and are safe.