This just uses an intermediate variable of the correct type to store the
result, and then casts it, as the value is guaranteed to be a number
between 0 and 7.
/* Process per-word as long as we have at least a full word left */
do { /* Commit 03c1e4ab1d6ee9062fb3f94b0ba31db6698724b1 contains an
explanation of how this works */
- count += ((((* (PERL_UINTMAX_T *) x) & PERL_VARIANTS_WORD_MASK) >> 7)
+ PERL_UINTMAX_T increment
+ = ((((* (PERL_UINTMAX_T *) x) & PERL_VARIANTS_WORD_MASK) >> 7)
* PERL_COUNT_MULTIPLIER)
>> ((PERL_WORDSIZE - 1) * CHARBITS);
+ count += (Size_t) increment;
x += PERL_WORDSIZE;
} while (x + PERL_WORDSIZE <= e);
}