Fixes for LLP64 systems (i.e. Windows 64bit) - #6538
Open
fingolfin wants to merge 3 commits into
Open
Conversation
4096L*1024*1024 overflows the 32-bit long of LLP64 systems (native Windows); compute the default allocation pool sizes in UInt. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
COUNT_TRUES_BLOCK used __builtin_popcountl, whose argument type 'unsigned long' has only 32 bits on LLP64 systems such as native Windows: bits at positions >= 32 of each block were silently not counted. In particular, every filter with flag number above 32 appeared to have empty flags, which derailed the type system early in the library bootstrap -- the mysterious breakage observed in PR #6077. With this fix, GAP starts up and computes correctly on native Windows (mingw). Select the popcount builtin matching the size of UInt, the same way CLog2UInt in integer.c already selects among the clz builtins. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
GMP's mpz_*_ui functions take 'unsigned long', which has only 32 bits on LLP64 systems (native Windows), so passing a UInt silently truncates. In particular GcdInt(<large>, 2^50) returned Gcd(x,0)=0, sending rational arithmetic into an infinite loop (found via a hang in ctblmoli.tst). - GcdInt: use mpn_gcd_1, whose small operand is an mp_limb_t - FACTORIAL_INT: raise an error for n above ULONG_MAX (the result would be astronomically large anyway) - BINOMIAL_INT: return Fail for k above ULONG_MAX, matching the existing policy for multi-limb k, and route n above ULONG_MAX through the mpz_bin_ui branch No behavior change on LP64 systems. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
fingolfin
force-pushed
the
mh/llp64-fixes
branch
from
August 29, 2026 14:35
9d0370a to
31a20d6
Compare
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #6538 +/- ##
==========================================
- Coverage 79.00% 78.97% -0.03%
==========================================
Files 684 684
Lines 294205 294207 +2
Branches 8647 8673 +26
==========================================
- Hits 232444 232363 -81
- Misses 59955 60034 +79
- Partials 1806 1810 +4 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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.
This contains three commits which fix various issues on LLP64 systems (where
sizeof(long)==4yetsizeof(void*)==8).COUNT_TRUES_BLOCKused__builtin_popcountl, ignoring bits >= 32 of every block. Every filter with flag number above 32 looked empty, derailing the type system during library bootstrap -- the unexplained breakage in Fix Windows/MinGW compilation issues #6077. Now selects the popcount builtin matchingUInt, likeCLog2UIntdoes for clz.mpz_*_uitakeunsigned long.GcdInt(<large>, 2^50)computedGcd(x, 0) = 0, sending rational arithmetic into an infinite loop (a hang inctblmoli.tst).GcdIntnow usesmpn_gcd_1;FACTORIAL_INTerrors andBINOMIAL_INTreturnsfailaboveULONG_MAX.4096L*1024*1024overflows a 32-bitlong; compute the default pool sizes inUInt.These are part of a port of GAP to MingW Claude Fable 5 wrote for me (see also issue #4157), but they are clearly of independent use, and therefore in a PR of their own.
Co-Authored-By: Claude Fable 5 noreply@anthropic.com