Conversation
std::min takes both arguments as a single deduced const _Tp&, so it needs one type. Ten call sites mixed a size_t-typed expression -- the result of GetMaxAllowedDeviceMemoryUsage() / sizeof(...) -- with a uint64_t iteration bound, which cannot deduce on any target where those two are spelled differently. That is Darwin (size_t is unsigned long, uint64_t is unsigned long long, both 8 bytes) and any ILP32 target (4-byte size_t, 8-byte uint64_t). It compiles on Linux LP64 and Windows LLP64 only because the spellings happen to coincide there, so the bug is latent rather than absent on those hosts. The fix is the idiom already used by the adjacent batch-size clamps a few lines below each site, e.g. unary_common.hh:61 -- an explicit std::min<uint64_t>. Widening to uint64_t rather than narrowing to size_t matters on ILP32, where narrowing would truncate. No behavioural change on LP64: the two types are the same width and the values are unaffected; this only lets deduction succeed.
pvelesko
force-pushed
the
develop-chipstar
branch
from
September 8, 2026 14:57
c6b9cfe to
2581d67
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.
std::mindeduces a single_Tpfor both parameters, so both arguments must have the sametype. Ten call sites under
catch/unit/math/mix asize_t-typed expression — the resultof
GetMaxAllowedDeviceMemoryUsage() / sizeof(...)— with auint64_titeration bound:That fails to deduce on any target where
size_tanduint64_tare spelled differently:size_tisunsigned long,uint64_tisunsigned long longi386/armv7: 4-bytesize_tvs 8-byteuint64_tIt compiles on Linux LP64 and Windows LLP64 only because the two spellings coincide there,
so this is latent rather than absent on those hosts.
The fix uses the idiom already present a few lines below each of these sites — for example
unary_common.hh:61— an explicitstd::min<uint64_t>. Widening touint64_trather thannarrowing to
size_tis the correct direction: on LP64 the two are both 8 bytes so nothingchanges, while on ILP32 narrowing would truncate.
No behavioural change: on LP64 the types are the same width and the values are unaffected.
This only lets deduction succeed.
Files touched:
unary_common.hh,binary_common.hh,ternary_common.hh,quaternary_common.hh,casting_common.hh,pow_common.hh,special_common.hh.Scope
This does not by itself make
MathsTestbuild on macOS — there are further, unrelatedfailures in that target. I opened a separate issue covering those: CHIP-SPV/chipStar/issues/1583