Skip to content

fix(avr): gamut_map kGamutProbeCeilingQ16 = 4 << 16 overflows 16-bit int #5303

Closed

Description

@zackees

Problem

src/fl/gfx/gamut_map.cpp.hpp:38:

constexpr i32 kGamutProbeCeilingQ16 = 4 << 16;

On AVR int is 16 bits, so 4 << 16 shifts past the width of the type. avr-gcc 7.3 rejects it ("left shift count >= width of type", hard error in a constexpr context); with -fpermissive it compiles to a wrong value (0), which would make the gamut probe ceiling zero and break gamut mapping on AVR.

Found while measuring stack usage of all src/fl/build/*.cpp unity files with avr-gcc -fstack-usage (same 16-bit-int bug class as #5301).

Proposed solution

  • constexpr i32 kGamutProbeCeilingQ16 = i32(4) << 16;
  • Sweep src/ for other integer-literal shifts by >= 16 that rely on 32-bit int (a grep of constexpr i32/u32 X = N << 16..31 found only this one, but also check non-constexpr and #define forms).
  • Consider a lint rule (Rust linter in ci/lint_cpp_rs/) that flags a bare int literal shifted left by >= 16 in src/, since host tests can't catch this class.
  • Verify with an avr-gcc compile of the unity file without -fpermissive.

Activity

  1. added
    type: bug
    platform: avr
    on Nov 20, 2026
  2. added
    sanitized
    on Nov 20, 2026
  3. moved this from Triage to Done in FastLED Trackeron Nov 20, 2026
  4. added a commit that references this issue on Nov 20, 2026
    eed5a80
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    platform: avrsanitizedtype: bug

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions