make_unsigned_detail::unsigned_by_size<4> was `unsigned int`, which is
16-bit on AVR, so make_unsigned<u32/i32/long>::type silently truncated
to 16 bits there. That broke fl::popcount / fl::countr_zero for u32 on
AVR after #5291 (CodeRabbit review on #5291), and fl::format's
format_integer for 32-bit values.
Select `unsigned long` when `unsigned int` is not 4 bytes; every other
target is unchanged. Namespace-scope static_asserts now check the width
of make_unsigned<short/int/long/long long> on every build.
Verified with avr-g++ (atmega328p): the asserts fail before the fix;
after it, popcount(u32 0x011fffff) folds to 22, countr_zero(u32
0x00010000) to 16, popcount(i8 -1) to 8.
Follow-up to #5291. Fixes the unresolved CodeRabbit finding there, which was posted after the merge.
Problem
fl::make_unsignedselects by size, andunsigned_by_size<4>wasunsigned int. That type is 16 bits on AVR, somake_unsigned<u32/i32/long>::typewas 16 bits there. #5291 madefl::popcount/fl::countr_zeroconvert throughmake_unsigned, so on AVRpopcount(u32(0x011fffff))still returned 16 andcountr_zero(u32(0x00010000))reached__builtin_ctz(0).fl::format'sformat_integertruncated 32-bit values the same way.Fix
unsigned_by_size<4>usesunsigned longwhenunsigned intis not 4 bytes. Every other target keepsunsigned int, so no type changes there.make_unsigned<short/int/long/long long>on every build, AVR CI included.Evidence
popcount(u32 0x011fffff)folds to 22,countr_zero(u32 0x00010000)to 16 andpopcount(i8 -1)to 8 (checked in the generated assembly).bash test --cpp,bash lint,bash compile uno --examples Blinkall pass.Summary by CodeRabbit