Skip to content

Fix shift count overflow on AVR in simplex snoise16#1692

Merged
zackees merged 1 commit into
FastLED:masterfrom
tttapa:patch-1
Sep 2, 2024
Merged

Fix shift count overflow on AVR in simplex snoise16#1692
zackees merged 1 commit into
FastLED:masterfrom
tttapa:patch-1

Conversation

@tttapa
Copy link
Copy Markdown
Contributor

@tttapa tttapa commented Sep 1, 2024

1 << 27 overflows on AVR because the int 1 is only 16 bits.

/home/runner/Arduino/libraries/FastLED/src/simplex.cpp: In function 'uint16_t snoise16(uint32_t, uint32_t)':
/home/runner/Arduino/libraries/FastLED/src/simplex.cpp:160:25: warning: left shift count >= width of type [-Wshift-count-overflow]
     int32_t t0 = ((1 << 27) - x0*x0 - y0*y0) >> 12; // .16
                         ^~
/home/runner/Arduino/libraries/FastLED/src/simplex.cpp:167:25: warning: left shift count >= width of type [-Wshift-count-overflow]
     int32_t t1 = ((1 << 27) - x1*x1 - y1*y1) >> 12; // .16
                         ^~
/home/runner/Arduino/libraries/FastLED/src/simplex.cpp:174:25: warning: left shift count >= width of type [-Wshift-count-overflow]
     int32_t t2 = ((1 << 27) - x2*x2 - y2*y2) >> 12; // .16
                         ^~

@zackees zackees merged commit bc23fe3 into FastLED:master Sep 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants